一个动画效果
by 伍雪颖
#define SCREEN_WIDTH ([UIScreen mainScreen].bounds.size.width)
@interface
ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super
viewDidLoad];
UIView *view = [[UIView
alloc]
initWithFrame:CGRectMake(100,
100,
100,
100)];
view.backgroundColor = [UIColor
redColor];
[self.view
addSubview:view];
view.transform =
CGAffineTransformMakeTranslation(SCREEN_WIDTH,
0);
[UIView
animateWithDuration:0.5
delay:0
usingSpringWithDamping:0.7
initialSpringVelocity:0
options:0
animations:^{
view.transform =
CGAffineTransformIdentity;
} completion:NULL];
}
时间: 2024-10-12 16:18:50