UIImageView 上面放一個button(或者其他的控件,需要添加手勢或者點擊事件)時,如果點擊的事件不觸發時
我們需要把UIImageView與用戶的交互打開
例如:
UIImageView * Image = [[UIImageViewalloc]initWithFrame:CGRectMake(0,0,ScreenWidth, 215 *FitHeight)];
Image.image = [UIImageimageNamed:@"userbackground@2x"];
//imageView打開用戶交互
Image.userInteractionEnabled = YES;
[self.viewaddSubview:Image];
//跳過按鈕
UIButton * SkipButton = [[UIButtonalloc]initWithFrame:CGRectMake(ScreenWidth - 70 * FitWidth,25 * FitHeight,50 * FitWidth,50 * FitHeight)];
[SkipButton setTitle:@"跳過"forState:UIControlStateNormal];
[SkipButton setTintColor:littleLabelColor];
SkipButton.titleLabel.font =littleLabelFont;
[SkipButton addTarget:selfaction:@selector(SkipButtonAction)forControlEvents:UIControlEventTouchUpInside];
[BackgroundPicture addSubview:SkipButton];
#PRagma mark 跳過的點擊事件
-(void)SkipButtonAction{
[self.navigationControllerpopViewControllerAnimated:YES];
}
新聞熱點
疑難解答