Animating UIView frame.origin
FWIW, it's nice to have a UIView category around for this type of thing:
@interface UIView (JCUtilities)
@property (nonatomic, assign) CGFloat frameX;
-(CGFloat)frameX;
-(void)setFrameX:(CGFloat)newX;
@end
@implementation UIView (JCUtilities)
- (CGFloat)frameX {
return self.frame.origin.x;
}
- (void)setFrameX:(CGFloat)newX {
self.frame = CGRectMake(newX, self.frame.origin.y,
self.frame.size.width, self.frame.size.height);
}
I have solved this problem. The technique I discovered is to assign your view's frame to another CGRect, and make changes to that CGRect, then assign it back to the frame:
CGRect frame = self.moveView.frame;
frame.origin.x = newvalue.
[UIView animateWithDuration:2.0 animations:^{
self.moveView.frame = frame;
}];