美文网首页
选择城市的小Demo

选择城市的小Demo

作者: leaderleader | 来源:发表于2017-11-18 11:18 被阅读0次

// AppDelegate.m

#import "ViewController.h"

ViewController *VC = [[ViewController alloc] init];

UINavigationController *NAV = [[UINavigationController alloc]initWithRootViewController:VC];

self.window.rootViewController = NAV;

self.window.backgroundColor = [UIColor whiteColor];

// ViewController.m

//城市第三方

#import "CityPcker/CityPickerViewController.h"

#import "CityModel.h"

<CAAnimationDelegate>

//==================================================

//城市按钮

UIButton* city = [UIButton buttonWithType:UIButtonTypeRoundedRect];

city.frame = CGRectMake(100, 2, 60, 15);

[city setTitle:@"城 市 ∨" forState:UIControlStateNormal ];

[city addTarget:self action:@selector(Cit:) forControlEvents:UIControlEventTouchUpInside];

UIBarButtonItem * cityButton = [[UIBarButtonItem alloc]initWithCustomView:city];

self.navigationItem.leftBarButtonItem = cityButton;

//===========================================

//城市添加按钮方法

-(void)Cit:(UIButton*)sender

{

CityPickerViewController *vc = [CityPickerViewController new];

[self BottomPushViewController:vc];

vc.selectCityModelHandler = ^(CityModel *model)

{

[sender setTitle:model.CityName forState:0];

};

}

#pragma mark 向上推入动画

-(void)BottomPushViewController:(UIViewController *)VC

{

CATransition *transition = [CATransition animation];

transition.duration = 0.4f;

transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];

transition.type = kCATransitionMoveIn;

transition.subtype = kCATransitionFromTop;

transition.delegate = self;

[self.navigationController.view.layer addAnimation:transition forKey:nil];

[self.navigationController pushViewController:VC animated:NO];

}

注:加入sqlite3

倒入第三方CityPcker

相关文章

网友评论

      本文标题:选择城市的小Demo

      本文链接:https://www.haomeiwen.com/subject/rerevxtx.html