Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8129373
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T08:17:18+00:00 2026-06-06T08:17:18+00:00

I have a view which has two labels. When I swipe left I fill

  • 0

I have a view which has two labels. When I swipe left I fill next content to label text. Similarly swiping right loads previous content. I want to give an effect to labels like they are scrolling from left or right.
I used a scrollview before but it had a memory problem. So I’m using one view, and swipe gesture loads next or previous content. I want to add scrollview’s sliding effect to labels. How can I do that?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T08:17:20+00:00Added an answer on June 6, 2026 at 8:17 am

    I’m not quite sure precisely what effect you’re looking for, but you could do something like this, which creates a new, temporary label, puts it off screen, animates the moving it over the label you have on screen, and then when done, resets the old one and deletes the temporary label. This is what a non-autolayout implementation might look like:

    - (void)viewDidLoad
    {
        [super viewDidLoad];
        // Do any additional setup after loading the view.
    
        UISwipeGestureRecognizer *left = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(leftSwipe:)];
        [left setDirection:UISwipeGestureRecognizerDirectionLeft];
        [self.view addGestureRecognizer:left];
        // if non-ARC, release it
        // [release left];
    
        self.label1.text = @"Mo";
    }
    
    - (void)leftSwipe:(UISwipeGestureRecognizer *)gesture
    {
        NSString *newText;
        UILabel  *existingLabel = self.label1;
    
        // in my example, I'm just going to toggle the value between Mo and Curly
    
        if ([existingLabel.text isEqualToString:@"Curly"])
            newText = @"Mo";
        else
            newText = @"Curly";
    
        // create new label
    
        UILabel *tempLabel = [[UILabel alloc] initWithFrame:existingLabel.frame];
        [existingLabel.superview addSubview:tempLabel];
        tempLabel.text = newText;
    
        // move the new label off-frame to the right
    
        tempLabel.transform = CGAffineTransformMakeTranslation(tempLabel.superview.bounds.size.width, 0);
    
        // animate the sliding of them into place
    
        [UIView animateWithDuration:0.5
                         animations:^{
                             tempLabel.transform = CGAffineTransformIdentity;
                             existingLabel.transform = CGAffineTransformMakeTranslation(-existingLabel.superview.bounds.size.width, 0);
                         }
                         completion:^(BOOL finished) {
                             existingLabel.text = newText;
                             existingLabel.transform = CGAffineTransformIdentity;
                             [tempLabel removeFromSuperview];
                         }];
    
        // if non-ARC, release it
        // [release tempLabel];
    }
    

    This animation animates the label with respect to its superview. You may want to ensure that the superview is set to “clip subviews”. This way, the animation will be constrained to the bounds of that superview, which yields a slightly more polished look.

    Note, if using auto layout, the idea is the same (though the execution is more complicated). Basically configure your constraints so new view is off to the right, then, in animation block update/replace the constraints so the original label is off to the left and the new one is in the spot of the original label, and, finally, in the completion block reset the constraints of the original label and remove the temporary label.


    By the way, this is all infinitely easier if you’re comfortable with one of the built in transitions:

    - (void)leftSwipe:(UISwipeGestureRecognizer *)gesture
    {
        NSString *newText;
        UILabel  *existingLabel = self.label1;
    
        // in my example, I'm just going to toggle the value between Mo and Curly
    
        if ([existingLabel.text isEqualToString:@"Curly"])
            newText = @"Mo";
        else
            newText = @"Curly";
    
        [UIView transitionWithView:existingLabel  // or try `existingLabel.superview`
                          duration:0.5
                           options:UIViewAnimationOptionTransitionFlipFromRight
                        animations:^{
                            existingLabel.text = newText;
                        }
                        completion:nil];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a XML layout which has two edit text fields, one for title
I have an activity which has two edit text fields: one for the title
I have an asp.net view which has two partial views. One for edit information
I have an view in my App which has a number of buttons based
I have a DatePicker working on a View which also has a ViewModel associated
I have an iPhone app which has a Table View-based data input screen with
I have a scrollview which has to display a view larger than the available
In my IB I have a navigation controller which has in it a view
I have a navigation controller which also has a table view. I want to
I have senario in which one view and view has binding with multiple ViewModel.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.