I had a similar problem when resizing UILabel during autorotation and solving it using CADisplayLink like this.
First call displayLinkTimer in the willAnimateRotationToInterfaceOrientation method.
displayLinkTimer = [CADisplayLink displayLinkWithTarget:self selector:@selector(resizeTextLabel)]; [displayLinkTimer addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
Then resize the label by resizing it at the same speed as the invisible UIView that I created using textView. The TextView has a frame identical to what I want my UILabel frame to be and its size is changed in the willAnimateRotationToInterfaceOrientation method. I was able to resize at the same speed by accessing the textView presentationLayer.
- (void)resizeTextLabel{ if (UIDeviceOrientationIsLandscape([UIDevice currentDevice].orientation)) { if (textLabel.frame.size.width < textView.frame.size.width -20) { textLabel.frame = CGRectMake(0, 0, [[textView.layer presentationLayer] frame].size.width, [[textView.layer presentationLayer] frame].size.height); }else{ [timer invalidate]; timer = nil; } } else{ if (textLabel.frame.size.width > textView.frame.size.width -20) { textLabel.frame = CGRectMake(0, 0, [[textView.layer presentationLayer] frame].size.width, [[textView.layer presentationLayer] frame].size.height); }else{ [timer invalidate]; timer = nil; } } }
Hope this helps someone.
source share