//AppDalegate部分
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; // Override point for customization after application launch. self.window.backgroundColor = [UIColor whiteColor]; [self.window makeKeyAndVisible]; //设置view和导航 ViewController1 *viewCtrl1 = [[ViewController1 alloc] init]; UINavigationController *navi = [[UINavigationController alloc] initWithRootViewController:viewCtrl1]; navi.navigationBarHidden = YES; self.window.rootViewController = navi; return YES; }
//封装按钮
- (UIButton *)gzybutton:(NSString *)image andFrame:(CGRect)frame0 andAction:(SEL)action0
{
UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
UIImage *image1 = [UIImage imageNamed:image];
[btn setImage:image1 forState:UIControlStateNormal];
[btn addTarget:self action:action0 forControlEvents:UIControlEventTouchUpInside];
btn.frame = frame0;
[self.view addSubview:btn];
return btn;
}
//封装视图
- (UIImageView *)gzyView :(NSString *)image0 andFram :(CGRect)fram
{
UIImageView *imageView = [[UIImageView alloc] initWithFrame:fram];
UIImage *image = [UIImage imageNamed:image0];
[imageView setImage:image];
[self.view addSubview:imageView];
return imageView;
}
//-------------------------------华丽的分割线----------------------------------
//加载视图
- (void) loadImage
{
[self gzyView:@"main_Bg" andFram:CGRectMake(0, 0, 320, 580)];
}
//加载按钮
- (void) creatBtn
{
[self gzybutton:@"main_study" andFrame:CGRectMake(10, 400, 93, 163) andAction:@selector(nextPage:)];
}
//按钮的功能
- (void) nextPage :(UIButton *)sender
{
ViewController2 *viewCtrl2 = [[ViewController2 alloc]init];
[self.navigationController pushViewController:viewCtrl2 animated:YES];
}
- (void)viewDidLoad
{
[super viewDidLoad];
[self loadImage];
[self creatBtn];
}
第二个viewController
//封装按钮
- (UIButton *)gzybutton:(NSString *)image andFrame:(CGRect)frame0 andAction:(SEL)action0
{
UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
UIImage *image1 = [UIImage imageNamed:image];
[btn setImage:image1 forState:UIControlStateNormal];
[btn addTarget:self action:action0 forControlEvents:UIControlEventTouchUpInside];
btn.frame = frame0;
[self.view addSubview:btn];
return btn;
}
//封装所有日文按钮
- (UIButton *) japanNextFram :(CGRect)fram andAction :(SEL)action
{
UIButton *btn3 = [UIButton buttonWithType:UIButtonTypeCustom];
btn3.frame = fram;
// btn3.backgroundColor = [UIColor clearColor];
btn3.backgroundColor = [UIColor clearColor];
[btn3 addTarget:self action:action forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:btn3];
return btn3;
}
//封装视图
- (UIImageView *)gzyView :(NSString *)image0 andFram :(CGRect)fram
{
UIImageView *imageView = [[UIImageView alloc] initWithFrame:fram];
UIImage *image = [UIImage imageNamed:image0];
[imageView setImage:image];
[self.view addSubview:imageView];
return imageView;
}
//日文字母按钮
//- (void)kkk
//{
// UIButton *btn3 = [UIButton buttonWithType:UIButtonTypeCustom];
// btn3.frame = CGRectMake(20, 24, 101, 80);
//// btn3.backgroundColor = [UIColor clearColor];
// btn3.backgroundColor = [UIColor yellowColor];
// [btn3 addTarget:self action:@selector(<#selector#>) forControlEvents:UIControlEventTouchUpInside];
// [self.view addSubview:btn3];
//
//}
//按钮
- (void) backBtn
{
[self gzybutton:@"backBtn" andFrame:CGRectMake(5, 25, 70, 35) andAction:@selector(back:)];
[self japanNextFram:CGRectMake(50, 74, 50, 60) andAction:@selector(gzyAiNext:)];
}
//按钮的方法
- (void) back :(UIButton *)sender
{
[self.navigationController popViewControllerAnimated:YES];
}
- (void) jumpAd :(UIButton *)sender
{
AdViewController *adView = [[AdViewController alloc] init];
UINavigationController *navi = [[UINavigationController alloc] initWithRootViewController:adView];
[self presentModalViewController:navi animated:YES];
}
- (void) gzyAiNext :(UIButton *)sender
{
ViewController3 *viewCTRL = [[ViewController3 alloc] init];
[self.navigationController pushViewController:viewCTRL animated:YES];
}
//视图
- (void) creatView
{
[self gzyView:@"bg_01_01" andFram:CGRectMake(0, 64, 320, 418)];
[self gzyView:@"titleView" andFram:CGRectMake(0, 20, 320, 49)];
}
//按钮
- (void) creatBtn
{
UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
[btn setTitle:@"advertisiment!!!" forState:UIControlStateNormal];
[btn setTitleColor:[UIColor purpleColor] forState:UIControlStateNormal];
btn.frame = CGRectMake(0, 480, 320, 70);
btn.backgroundColor = [UIColor grayColor];
[btn addTarget:self action:@selector(jumpAd:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:btn];
}
- (void)viewDidLoad
{
[super viewDidLoad];
[self creatView];
[self backBtn];
[self creatBtn];
// Do any additional setup after loading the view.
}



日语五十音图前几个页面关于导航器的简单代码分享,布布扣,bubuko.com
原文:http://www.cnblogs.com/gzy0724/p/3850131.html