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

  • Home
  • SEARCH
  • 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 4123314
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T23:35:44+00:00 2026-05-20T23:35:44+00:00

I would like to have two UITextViews, one in the background and one in

  • 0

I would like to have two UITextViews, one in the background and one in the front. Is there any possibility to crop 50% of the one in the foreground so that you can see 50% of the one in the background? I do not want to re-size the UITextView in the front, but merely to hide half of it.

I think an illustration is in place as this might sound rather confusing:

enter image description here

I thought I do this with two view controllers, one hidden, one visible:

// Visible and Hidden View 

VisibleView *visibleController = [[VisibleView alloc] initWithNibName:@"VisibleView" bundle:nil];
self.visibleView = visibleController;
[visibleController release];

HiddenView *hiddenController = [[HiddenView alloc] initWithNibName:@"HiddenView" bundle:nil];
self.hiddenView = hiddenController;
[hiddenController release];

[self.view insertSubview:visibleView.view atIndex:0]; // show visibleView

Ideally, I would like to animate the ‘hiding’ of the visibleView Controller, so that the hiddenViewController unveils in the background (like a sliding door – sliding in from the right). This is what I’ve come up so far, but I can’t think of any transformation / cropping technique that will do:

[UIView beginAnimations:@"Hide VisibleView" context:nil];
[UIView setAnimationDuration:0.5];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];   
[UIView setAnimationTransition: ??
                       forView: self.view
                         cache: YES];
[visibleView.view removeFromSuperview];                 
[self.view insertSubview:hiddenView.view atIndex:0];

[UIView commitAnimations];

I guess this is quite basic, but I’m still a beginner and would be very happy over any suggestions of how to accomplish this.

  • 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-05-20T23:35:44+00:00Added an answer on May 20, 2026 at 11:35 pm

    I just created a new View-Based Application project and put this code in the viewDidLoad of the viewController to get the screen shown. It shows the theory of what you need to do. The main points to note are the ‘clipsToBounds = true’ and the negative x-position of textFrameRight.

    - (void)viewDidLoad
    {
        [super viewDidLoad];
    
        NSString* text = @"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.";
        UIFont* font = [UIFont fontWithName:@"Helvetica" size:20.0f];
    
        CGRect textFrameLeft = CGRectMake(0, 0, 320, 480);
    
        UITextView* textLeft = [[UITextView alloc] initWithFrame:textFrameLeft];
        textLeft.text = text;
        textLeft.font = font;
        textLeft.textColor = [UIColor blackColor];
    
        CGRect textFrameRight = textFrameLeft;
        textFrameRight.origin.x -= textFrameRight.size.width/2;
    
        UITextView* textRight = [[UITextView alloc] initWithFrame:textFrameRight];
        textRight.text = text;
        textRight.font = font;
        textRight.textColor = [UIColor redColor];
    
        CGRect leftFrame = self.view.frame;
        leftFrame.size.width /= 2;
    
        UIView* leftView = [[UIView alloc] initWithFrame:leftFrame];
        leftView.clipsToBounds = true;
    
        CGRect rightFrame = self.view.frame;
        rightFrame.size.width -= leftFrame.size.width;
        rightFrame.origin.x += leftFrame.size.width;
    
        UIView* rightView = [[UIView alloc] initWithFrame:rightFrame];
        rightView.clipsToBounds = true;
    
        [self.view addSubview:leftView];
        [leftView addSubview:textLeft];
    
        [self.view addSubview:rightView];
        [rightView addSubview:textRight];
    
        [leftView release];
        [textLeft release];
        [rightView release];
        [textRight release];
    }

    Cropping UITextView

    ==================================

    Realising the OP wanted this to animate; here is a revised version of the above method which does such. There are more hard-coded values in this version; but it serves as an example.

    - (void)viewDidLoad
    {
        [super viewDidLoad];
    
        NSString* text = @"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.";
        UIFont* font = [UIFont fontWithName:@"Helvetica" size:20.0f];
    
        CGRect leftFrame = CGRectMake(0, 0, 0, 480);
        CGRect textFrameLeft = CGRectMake(0, 0, 0, 480);
    
        CGRect rightFrame = CGRectMake(0, 0, 320, 480);
        CGRect textFrameRight = CGRectMake(0, 0, 320, 480);
    
        UITextView* textLeft = [[UITextView alloc] initWithFrame:textFrameLeft];
        textLeft.text = text;
        textLeft.font = font;
        textLeft.textColor = [UIColor redColor];
    
        UITextView* textRight = [[UITextView alloc] initWithFrame:textFrameRight];
        textRight.text = text;
        textRight.font = font;
        textRight.textColor = [UIColor blackColor];
    
        UIView* leftView = [[UIView alloc] initWithFrame:leftFrame];
        leftView.clipsToBounds = true;
    
        UIView* rightView = [[UIView alloc] initWithFrame:rightFrame];
        rightView.clipsToBounds = true;
    
        [self.view addSubview:leftView];
        [leftView addSubview:textLeft];
    
        [self.view addSubview:rightView];
        [rightView addSubview:textRight];
    
        [UIView beginAnimations:@"Hide VisibleView" context:nil];
        [UIView setAnimationDuration:3.0];
        rightView.frame = CGRectMake(320, 0, 0, 480);
        textRight.frame = CGRectMake(-320, 0, 320, 480);
        leftView.frame = CGRectMake(0, 0, 320, 480);
        textLeft.frame = CGRectMake(0, 0, 320, 480);
        [UIView commitAnimations];
    
        [leftView release];
        [textLeft release];
        [rightView release];
        [textRight release];
    }
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to have a form that can submit to two different action
Ok, NHibernate question here. I have two objects that I would like to map
I have several A4 PDF documents which I would like (two into one) glue
I would like to have two different registrations/logins in the same application. One for
I have two XmlDocuments and I would like to move an XmlNode selected from
I have two strings and would like to display the difference between them. For
I have two strings and I would like to mix the characters from each
I have two unix partitions under debian which I would like to merge (disk
I have two tables A and B. I would like to delete all the
I have two points (a line segment) and a rectangle. I would like to

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.