- (void)viewDidAppear:(BOOL)animated{
[super viewDidAppear:animated];
UIImageView *circleView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"face.png"]];
circleView.frame = CGRectMake(0, 0, 200, 200);
circleView.layer.cornerRadius = 100;
circleView.center = self.view.center;
[self.view addSubview:circleView];
circleView.transform = CGAffineTransformMakeScale(0, 0);
[UIView animateWithDuration:1 delay:0 usingSpringWithDamping:.5 initialSpringVelocity:1 options:0 animations:^{
circleView.transform = CGAffineTransformMakeScale(1, 1);
} completion:nil];
如您所见,我在此动画方法中创建了一个名为circleView的视图。然后,我创建了一个touchesBegan方法,我想在触摸屏幕时再次浏览动画。我该怎么做?
答案 0 :(得分:0)
正如Sujay所说,创建一个新方法并在该方法中放入以下行。从touchBegan方法调用该方法。
circleView.transform = CGAffineTransformMakeScale(0, 0);
[UIView animateWithDuration:1 delay:0 usingSpringWithDamping:.5 initialSpringVelocity:1 options:0 animations:^{
circleView.transform = CGAffineTransformMakeScale(1, 1);
} completion:nil];
答案 1 :(得分:0)
我做到了。我创建了2个属性,然后我制作了一个小的动画,然后是另一个让它变得更大的动画。