给图片添加一个手势
calenDarView1 = [[UIImageView alloc]initWithFrame:CGRectMake(ScreenWidth/12, CGRectGetMaxY(lineBacView.frame)+15, ScreenWidth/6, ScreenWidth/5)];
calenDarView1.image = [UIImage imageNamed:@"xxx.png"];
[self.view addSubview:calenDarView1];
calenDarView1.userInteractionEnabled = YES;
UITapGestureRecognizer * PrivateLetterTap=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapAvatarView:)];
PrivateLetterTap.numberOfTouchesRequired = 1; //手指数
PrivateLetterTap.numberOfTapsRequired = 1; //tap次数
PrivateLetterTap.delegate= self;
calenDarView1.contentMode = UIViewContentModeScaleToFill;
[calenDarView1 addGestureRecognizer:PrivateLetterTap];
手势方法里面写调用日历的方法
- (void)tapAvatarView: (UITapGestureRecognizer *)gesture
{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"calshow:"]];
}
网友评论