간단한 전체 화면 탐색
ViewController
#import "ViewController.h"
#import "SecondViewController.h"
@interface ViewController ()
@property(nonatomic, strong)UIImageView *imageView;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor whiteColor];
self.imageView = [[UIImageView alloc]initWithFrame:CGRectMake(100, 200, 200, 300)];
_imageView.image = [UIImage imageNamed:@"h1.jpg"];
_imageView.userInteractionEnabled = YES;
[self.view addSubview:_imageView];
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapAction)];
[_imageView addGestureRecognizer:tap];
}
-(void)tapAction
{
SecondViewController *secondVC = [[SecondViewController alloc] init];
[self.navigationController pushViewController:secondVC animated:NO];// NO
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
이 작은 그림을 클릭한 후 두 번째 ViewController로 이동합니다. 여기서 점프 애니메이션을 NO로 설정하고 두 번째 ViewController가 나올 때 투명도를 0.2에서 1로 점차적으로 바꿔야 합니다. 여러분은 효과를 상상할 수 있습니다.
SecondViewController
#import "SecondViewController.h"
#define Width self.view.frame.size.width
#define Height self.view.frame.size.height
@interface SecondViewController ()
@property(nonatomic, strong)UIScrollView *scrollView;
@end
@implementation SecondViewController
-(void)viewWillAppear:(BOOL)animated
{
self.navigationController.navigationBarHidden = YES;//
/* View 1*/
self.view.alpha = .2;
[UIView animateWithDuration:1 animations:^{
self.view.alpha = 1;
}];
}
-(void)viewWillDisappear:(BOOL)animated
{
/* */
self.navigationController.navigationBarHidden = NO;
}
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor blackColor];
self.scrollView = [[UIScrollView alloc]initWithFrame:self.view.frame];
_scrollView.bounces = NO;
_scrollView.contentSize = CGSizeMake(Width * 7, Height);
_scrollView.contentOffset = CGPointMake(0, 0);
_scrollView.pagingEnabled = YES;
for (NSInteger i = 1; i < 8; i++) {
UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(Width * (i - 1), 0, Width, Height)];
imageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"h%ld.jpg", i]];
imageView.userInteractionEnabled = YES;
[_scrollView addSubview:imageView];
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapAction)];
[imageView addGestureRecognizer:tap];
}
[self.view addSubview:_scrollView];
}
-(void)tapAction
{
// , View 0.2 ,
[UIView animateWithDuration:0.6 animations:^{
self.view.alpha = .2;
} completion:^(BOOL finished) {
[self.navigationController popToRootViewControllerAnimated:NO];
}];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
아마 이 사고방식일 거예요. 아주 간단해요. 여러분은 계속 보완할 수 있어요.저에게 조언을 해주셔도 됩니다. 감사합니다. 오늘은 여기까지입니다.☺️
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
다양한 언어의 JSONJSON은 Javascript 표기법을 사용하여 데이터 구조를 레이아웃하는 데이터 형식입니다. 그러나 Javascript가 코드에서 이러한 구조를 나타낼 수 있는 유일한 언어는 아닙니다. 저는 일반적으로 '객체'{}...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.