iOS: Using UIView’s ‘drawRect:’ vs. its layer’s delegate ‘drawLayer:inContext:’

How to decide which approach to use? Is there a use case for each one? Always use drawRect:, and never use a UIView as the drawing delegate for any CALayer. how come the delegate method is called if my instance is not defined to be the layer’s delegate? and what mechanism prevents drawRect from being … Read more

How can I animate the movement of a view or image along a curved path?

To expand upon what Nikolai said, the best way to handle this is to use Core Animation to animate the motion of the image or view along a Bezier path. This is accomplished using a CAKeyframeAnimation. For example, I’ve used the following code to animate an image of a view into an icon to indicate … Read more

How to animate the background color of a UILabel?

I can’t find it documented anywhere, but it appears the backgroundColor property of UILabel is not animatable, as your code works fine with a vanilla UIView. This hack appears to work, however, as long as you don’t set the background color of the label view itself: #import <QuartzCore/QuartzCore.h> … theLabel.layer.backgroundColor = [UIColor whiteColor].CGColor; [UIView animateWithDuration:2.0 … Read more

How to animate the textColor property of an UILabel?

Instead, have you tried using a crossfade transition on the object itself like this, it’ll give you a nice fade-in fade-out effect from one color to another: Objective C [UIView transitionWithView:myLabel duration:0.25 options:UIViewAnimationOptionTransitionCrossDissolve animations:^{ myLabel.textColor = NEW_COLOR; } completion:^(BOOL finished) { }]; Swift 5 UIView.transition(with: creditsLabel, duration: 0.25, options: .transitionCrossDissolve) { self.creditsLabel.textColor = .red } … Read more

UIView shake animation

I wrote that post. It’s overkill for a UIView, plus the parameters are geared toward an OSX app. Do this instead. CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@”position”]; [animation setDuration:0.05]; [animation setRepeatCount:8]; [animation setAutoreverses:YES]; [animation setFromValue:[NSValue valueWithCGPoint: CGPointMake([lockView center].x – 20.0f, [lockView center].y)]]; [animation setToValue:[NSValue valueWithCGPoint: CGPointMake([lockView center].x + 20.0f, [lockView center].y)]]; [[lockView layer] addAnimation:animation forKey:@”position”]; You’ll … Read more

Leaking views when changing rootViewController inside transitionWithView

I had a similar issue recently. I had to manually remove that UITransitionView from the window to fix the problem, then call dismiss on the previous root view controller to ensure its deallocated. The fix is not really very nice but unless you’ve found a better way since posting the question, its the only thing … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)