我现在被难住了,我希望通过在手指放置的位置周围创建一个 UIView 来在手指按下时制定一个 UIView 动画。这可能吗?
- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch * touch = [touches anyObject];
CGPoint pos = [touch locationInView: [UIApplication sharedApplication].keyWindow];
NSLog(@"Position of touch: %.3f, %.3f", pos.x, pos.y);
//CGRect touchFrame = CGRectMake(pos.x, pos.y, 100, 100);
UIView *box = [[UIView alloc] initWithFrame:CGRectMake(pos.x, pos.y, 100, 100)];
NSLog(@"%f", box.frame.origin.x);
[self.view addSubview:box];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0];
[UIView setAnimationTransition:110 forView:box cache:NO];
[UIView commitAnimations];
[box removeFromSuperview];
[box release];
}
任何建议都非常受欢迎。