嘿傢伙, 我現在只是在這裏難住,我希望在手指按下時創建一個UIView動畫,通過在手指放置位置創建一個UIView。這可能嗎?iPhone - 在觸摸位置使用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];
}
任何建議都非常歡迎。
這是可能的,但到底是什麼問題? – Joze 2011-05-20 09:16:47
哎呀,對不起!這裏有點累了。運行時,不會對設置框區域產生影響。 – 2011-05-20 09:20:50
這應該通過設置視圖的邊界來解決,而不是像你這樣做。請參閱下面的答案。 – sergio 2011-05-20 09:40:21