2011-03-26 69 views
2

我有一个地图(只是一个图像),我希望用户可以点击地图上的一些地方。我想我可以通过添加按钮作为子视图。但我也想制作它们。因此,例如,想要在链接位置附近有一个环形表格。而且这个戒指应该像脉冲一样动画。我怎样才能做到最好的方式?如何创建一个带有按钮的地图(UIImage)动画?

迎接最大

回答

1

不知道为什么没有人试图回答这个问题,但它不是太困难。

首先,创建一个UIImageView并将其配置为动画效果。 UIImageView文档非常清楚要做什么。例如:

NSArray *imageArray = [NSArray arrayWithObjects: 
         [UIImage imageNamed:@"frame1.png], 
         [UIImage imageNamed:@"frame2.png], 
         ...,nil]; 

UIImageView *animatedImageView = [[UIImageView alloc] initWithFrame:myFrame]; 
animatedImageView.animatedImages = imageArray; 
animatedImageView.userInteractionEnabled = YES; 
[self.view addSubView:animatedImageView]; 
[animatedImageView startAnimating]; 

然后您必须添加代码以响应imageView上的触摸事件。

或者,您可以创建一个UIButton子类,该子类根据上述内容显示动画UIImageView,然后使用标准addTarget:action来响应用户操作。

相关问题