From ba7ab2b905be00ca32ea9a067100b086da55c651 Mon Sep 17 00:00:00 2001 From: Sunny Date: Sat, 9 Jun 2018 16:37:26 +0800 Subject: [PATCH 1/3] Ajust view. --- ChooseLocation/ViewController.m | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/ChooseLocation/ViewController.m b/ChooseLocation/ViewController.m index e6396c5..e220cd6 100644 --- a/ChooseLocation/ViewController.m +++ b/ChooseLocation/ViewController.m @@ -13,12 +13,17 @@ @interface ViewController () @property (nonatomic,strong) ChooseLocationView *chooseLocationView; @property (nonatomic,strong) UIView *cover; @property (weak, nonatomic) IBOutlet UILabel *addresslabel; +@property (nonatomic, assign) CGFloat scaling; @end +#define kScreenWidth [UIScreen mainScreen].bounds.size.width +#define kScreenHeight [UIScreen mainScreen].bounds.size.height + @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; + _scaling = 0.95; [[CitiesDataTool sharedManager] requestGetData]; [self.view addSubview:self.cover]; self.chooseLocationView.address = @"广东省 广州市 越秀区"; @@ -29,7 +34,8 @@ - (void)viewDidLoad { - (IBAction)chooseLocation:(UIButton *)sender { [UIView animateWithDuration:0.25 animations:^{ - self.view.transform =CGAffineTransformMakeScale(0.95, 0.95); + self.view.transform =CGAffineTransformMakeScale(_scaling, _scaling); + self.chooseLocationView.frame = CGRectMake(-(kScreenWidth * (1 - _scaling)), kScreenHeight - 350, kScreenWidth * (2.0 + _scaling), 350); }]; self.cover.hidden = !self.cover.hidden; self.chooseLocationView.hidden = self.cover.hidden; @@ -56,8 +62,7 @@ - (void)tapCover:(UITapGestureRecognizer *)tap{ - (ChooseLocationView *)chooseLocationView{ if (!_chooseLocationView) { - _chooseLocationView = [[ChooseLocationView alloc]initWithFrame:CGRectMake(0, [UIScreen mainScreen].bounds.size.height - 350, [UIScreen mainScreen].bounds.size.width, 350)]; - + _chooseLocationView = [[ChooseLocationView alloc]initWithFrame:CGRectMake(-(kScreenWidth * (1 - _scaling)), kScreenHeight, kScreenWidth * (2.0 + _scaling), 350)]; } return _chooseLocationView; } @@ -73,6 +78,9 @@ - (UIView *)cover{ [UIView animateWithDuration:0.25 animations:^{ weakSelf.addresslabel.text = weakSelf.chooseLocationView.address; weakSelf.view.transform = CGAffineTransformIdentity; + weakSelf.cover.alpha = 0; + weakSelf.chooseLocationView.frame = CGRectMake(-(kScreenWidth * (1 - _scaling)), kScreenHeight, kScreenWidth * (2.0 + _scaling), 350); + } completion:^(BOOL finished) { weakSelf.cover.hidden = YES; }]; }; @@ -81,6 +89,7 @@ - (UIView *)cover{ tap.delegate = self; _cover.hidden = YES; } + _cover.alpha = 1; return _cover; } @end From 9f049ccefafa2b0aa8ee877664ef21e03fdef4b4 Mon Sep 17 00:00:00 2001 From: Sunny Date: Sat, 9 Jun 2018 17:25:12 +0800 Subject: [PATCH 2/3] fix view bug.. --- ChooseLocation/ViewController.m | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/ChooseLocation/ViewController.m b/ChooseLocation/ViewController.m index e220cd6..b44ec98 100644 --- a/ChooseLocation/ViewController.m +++ b/ChooseLocation/ViewController.m @@ -9,21 +9,21 @@ #import "ViewController.h" #import "ChooseLocationView.h" #import "CitiesDataTool.h" + +#define kScreenWidth [UIScreen mainScreen].bounds.size.width +#define kScreenHeight [UIScreen mainScreen].bounds.size.height +const static CGFloat SCALING = 0.95; + @interface ViewController () @property (nonatomic,strong) ChooseLocationView *chooseLocationView; @property (nonatomic,strong) UIView *cover; @property (weak, nonatomic) IBOutlet UILabel *addresslabel; -@property (nonatomic, assign) CGFloat scaling; @end -#define kScreenWidth [UIScreen mainScreen].bounds.size.width -#define kScreenHeight [UIScreen mainScreen].bounds.size.height - @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; - _scaling = 0.95; [[CitiesDataTool sharedManager] requestGetData]; [self.view addSubview:self.cover]; self.chooseLocationView.address = @"广东省 广州市 越秀区"; @@ -34,8 +34,8 @@ - (void)viewDidLoad { - (IBAction)chooseLocation:(UIButton *)sender { [UIView animateWithDuration:0.25 animations:^{ - self.view.transform =CGAffineTransformMakeScale(_scaling, _scaling); - self.chooseLocationView.frame = CGRectMake(-(kScreenWidth * (1 - _scaling)), kScreenHeight - 350, kScreenWidth * (2.0 + _scaling), 350); + self.view.transform =CGAffineTransformMakeScale(SCALING, SCALING); + self.chooseLocationView.frame = CGRectMake(-(kScreenWidth * (1 - SCALING)), kScreenHeight - 350, kScreenWidth * (2.0 - SCALING), 350); }]; self.cover.hidden = !self.cover.hidden; self.chooseLocationView.hidden = self.cover.hidden; @@ -62,7 +62,7 @@ - (void)tapCover:(UITapGestureRecognizer *)tap{ - (ChooseLocationView *)chooseLocationView{ if (!_chooseLocationView) { - _chooseLocationView = [[ChooseLocationView alloc]initWithFrame:CGRectMake(-(kScreenWidth * (1 - _scaling)), kScreenHeight, kScreenWidth * (2.0 + _scaling), 350)]; + _chooseLocationView = [[ChooseLocationView alloc]initWithFrame:CGRectMake(-(kScreenWidth * (1 - SCALING)), kScreenHeight, kScreenWidth * (2.0 - SCALING), 350) withScaling:SCALING]; } return _chooseLocationView; } @@ -79,7 +79,7 @@ - (UIView *)cover{ weakSelf.addresslabel.text = weakSelf.chooseLocationView.address; weakSelf.view.transform = CGAffineTransformIdentity; weakSelf.cover.alpha = 0; - weakSelf.chooseLocationView.frame = CGRectMake(-(kScreenWidth * (1 - _scaling)), kScreenHeight, kScreenWidth * (2.0 + _scaling), 350); + weakSelf.chooseLocationView.frame = CGRectMake(-(kScreenWidth * (1 - SCALING)), kScreenHeight, kScreenWidth * (2.0 - SCALING), 350); } completion:^(BOOL finished) { weakSelf.cover.hidden = YES; }]; From ec43b4b326b7597cd7438f16fea100beb19031f5 Mon Sep 17 00:00:00 2001 From: Sunny Date: Sat, 9 Jun 2018 17:27:00 +0800 Subject: [PATCH 3/3] Fix label bug.. --- .../ChooseLocation/View/ChooseLocationView.h | 2 ++ .../ChooseLocation/View/ChooseLocationView.m | 27 +++++++++---------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/ChooseLocation/ChooseLocation/View/ChooseLocationView.h b/ChooseLocation/ChooseLocation/View/ChooseLocationView.h index bcf9ef0..ffdb198 100644 --- a/ChooseLocation/ChooseLocation/View/ChooseLocationView.h +++ b/ChooseLocation/ChooseLocation/View/ChooseLocationView.h @@ -16,4 +16,6 @@ @property (nonatomic,copy) NSString * areaCode; +- (instancetype)initWithFrame:(CGRect)frame withScaling:(CGFloat)scaling; + @end diff --git a/ChooseLocation/ChooseLocation/View/ChooseLocationView.m b/ChooseLocation/ChooseLocation/View/ChooseLocationView.m index 1458878..5602336 100644 --- a/ChooseLocation/ChooseLocation/View/ChooseLocationView.m +++ b/ChooseLocation/ChooseLocation/View/ChooseLocationView.m @@ -28,14 +28,15 @@ @interface ChooseLocationView ()