0
이렇게하면 오른쪽 상단 모서리에 이미지가 사라지는 "X"버튼이 약간 투명한 이미지가 나타납니다. 어떤 이유로 그것은 작동하지 않습니다! 이미지를 없애는 방법에 대한 아이디어가 있습니까? 버튼 어쩌면 내가 제대로 선택을 작성하지 않은버튼을 클릭하면 이미지 팝업이 닫히지 않습니다.
확인 ...
#define OVERLAY_TAG 997
-(void)showTutorial
{
UIWindow *keyWindow = [[UIApplication sharedApplication] keyWindow];
UIView *overlay = [[UIView alloc] initWithFrame:[UIScreen mainScreen].bounds];
overlay.backgroundColor = [UIColor clearColor];
overlay.userInteractionEnabled = YES;
[keyWindow addSubview:overlay];
UITapGestureRecognizer * tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self
action:@selector(dismissTutorial)];
CGFloat border = 10;
CGRect frame = overlay.bounds;
// 20 is the status bar height (sorry for using the number)
frame = CGRectMake(border, border + 20, frame.size.width - border * 2, frame.size.height - border * 2 - 20);
// the black view in the example is probably a scroll view
UIView *blackView = [[UIView alloc] initWithFrame:frame];
blackView.backgroundColor = [UIColor blackColor];
blackView.alpha = 0.7;
[overlay addSubview:blackView];
// add all the subviews for your tutorial
/*UIImage* image = [UIImage imageNamed:@"slide_image_3.png"];
UIImageView* info = [[UIImageView alloc] initWithImage:image];
info.frame = CGRectMake(0, 0, 200, 150);
[blackView addSubview:info];*/
UIImage* image4 = [UIImage imageNamed:@"close_img.png"];
dismissTut = [[UIButton alloc] initWithFrame:CGRectMake(250, 18, 26, 26)];
[dismissTut setBackgroundImage:image4 forState:UIControlStateNormal];
[dismissTut addTarget:self action:@selector(dismissTutorial)
forControlEvents:UIControlEventTouchUpInside];
[dismissTut setShowsTouchWhenHighlighted:YES];
[blackView addSubview:dismissTut];
// make it appear with an animation
[UIView animateWithDuration:0.3
animations:^{blackView.alpha = 0.6;}
completion:^(BOOL finished){[overlay addGestureRecognizer:tapRecognizer];}];
}
-(void)dismissTutorial
{
UIWindow *keyWindow = [[UIApplication sharedApplication] keyWindow];
UIView *overlay = [keyWindow viewWithTag:OVERLAY_TAG];
[UIView animateWithDuration:0.3
animations:^{
overlay.alpha = 0.0;
}
completion:^(BOOL finished){
[overlay removeFromSuperview];
}];
}
해제하려면 X를 누르거나하지 않으면 dismissTutorial이 호출됩니까? – incmiko
다른보기에서 다른 제스처를 사용하고 있습니까? – Wain
단추 작업 메서드에서 메서드를 호출했습니다. – Lalalalalala