// 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
网友评论