标签:style blog http color os 2014
AppDelegate.m部分 - (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]; FirstViewController *firstViewcontroller=[[FirstViewController alloc]init]; UINavigationController *navicontroller=[[UINavigationController alloc]initWithRootViewController:firstViewcontroller]; self.window.rootViewController=navicontroller; return YES; } @implementation FirstViewController - (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { // Custom initialization } return self; } - (void)viewDidLoad { [super viewDidLoad]; UIImageView *titleimageview=[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 320, 49)]; titleimageview.image=[UIImage imageNamed:@"btn2"]; [self.view addSubview:titleimageview]; UIImageView *imageview=[[UIImageView alloc]initWithFrame:CGRectMake(120, 1, 100, 60)]; imageview.image=[UIImage imageNamed:@"image1"]; [self.view addSubview:imageview]; self.navigationController.navigationBarHidden=YES; UIImageView *bgimageview=[[UIImageView alloc]initWithFrame:CGRectMake(0, 49, 320, 431)]; bgimageview.image=[UIImage imageNamed:@"bg_01"]; [self.view addSubview:bgimageview]; UIImageView *bgimageview1=[[UIImageView alloc]initWithFrame:CGRectMake(0, 49, 320, 431)]; bgimageview1.image=[UIImage imageNamed:@"bg_01_02"]; [self.view addSubview:bgimageview1]; UIButton *btn=[UIButton buttonWithType:UIButtonTypeCustom]; btn.frame=CGRectMake(50, 60, 53, 49); [btn addTarget:self action:@selector(didclick0:) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:btn]; // Do any additional setup after loading the view. } -(void)didclick0:(UIButton *)sender { sencondViewController *sencondviewcontroller=[[sencondViewController alloc]init]; [self.navigationController pushViewController:sencondviewcontroller animated:YES]; } //sencond部分 - (void)viewDidLoad { [super viewDidLoad]; [self createbgview]; [self createbtn]; // Do any additional setup after loading the view. } -(void)createbtn { //创建返回按键 UIButton *btn=[UIButton buttonWithType:UIButtonTypeCustom]; [btn setImage:[UIImage imageNamed:@"backBtn" ]forState: UIControlStateNormal]; btn.frame=CGRectMake(10, 6, 70, 35); [btn addTarget:self action:@selector(didclick0:)forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:btn]; //创建一个清除按键 UIButton *clearbtn=[UIButton buttonWithType:UIButtonTypeCustom]; [clearbtn setImage:[UIImage imageNamed:@"clearBtn"]forState:UIControlStateNormal]; clearbtn.frame=CGRectMake(240, 6, 70, 35); [clearbtn addTarget:self action:@selector(didclick1:) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:clearbtn]; //创建一个发音键 UIButton *voicebtn=[UIButton buttonWithType:UIButtonTypeCustom]; [voicebtn setImage:[UIImage imageNamed:@"pronounceBtn_01"]forState:UIControlStateNormal]; voicebtn.frame=CGRectMake(130,self.view.frame.size.height-52 ,67 ,52 ); [voicebtn setImage:[UIImage imageNamed:@"pronounceBtn_01"]forState:UIControlStateHighlighted]; [voicebtn addTarget:self action:@selector(didclick2:) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:voicebtn]; //创建一个训练键 UIButton *practicebtn=[UIButton buttonWithType:UIButtonTypeCustom]; [practicebtn setImage:[UIImage imageNamed:@"practiceBtn01"]forState:UIControlStateNormal]; practicebtn.frame=CGRectMake(240,self.view.frame.size.height-52 ,67 ,52 ); [practicebtn setImage:[UIImage imageNamed:@"ppracticeBtn01"]forState:UIControlStateHighlighted]; [practicebtn addTarget:self action:@selector(didclick3:) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:practicebtn]; //创建一个笔顺键 UIButton *bishunbtn=[UIButton buttonWithType:UIButtonTypeCustom]; [bishunbtn setImage:[UIImage imageNamed:@"bishun"]forState:UIControlStateNormal]; bishunbtn.frame=CGRectMake(10,self.view.frame.size.height-52 ,67 ,52 ); [bishunbtn setImage:[UIImage imageNamed:@"bishun"]forState:UIControlStateHighlighted]; [bishunbtn addTarget:self action:@selector(didclick4:) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:bishunbtn]; } -(void)createAnimation { aniImageView=[[UIImageView alloc]initWithFrame:CGRectMake(50, 70, 255, 255)]; NSMutableArray *array=[[NSMutableArray alloc]init]; aniImageView.image=[UIImage imageNamed:@"WA~0010"]; for(int i=1;i<=10;i++) { NSString *str=[NSString stringWithFormat:@"WA~%04d",i]; //UIImage *image=[[UIImage alloc]init]; UIImage *image=[UIImage imageNamed:str]; [array addObject:image]; } aniImageView.animationImages=array; //动画执行的时长,单位为秒 aniImageView.animationDuration = 4; //重复次数,默认为无限循环 aniImageView.animationRepeatCount = 1; [aniImageView startAnimating]; [self.view addSubview:aniImageView]; } -(void)didclick4:(UIButton*)sender{} -(void)didclick3:(UIButton*)sender { //练习键 [self createAnimation]; //[aniImageView startAnimating]; } -(void)didclick2:(UIButton*)sender{ //发音键 NSURL *url = [[NSBundle mainBundle] URLForResource:@"053_he" withExtension:@"mp3"]; AudioServicesCreateSystemSoundID((__bridge CFURLRef)(url), &soundID); AudioServicesPlaySystemSound(soundID); } -(void)didclick1:(UIButton *)sender { //清除按键 [aniImageView removeFromSuperview]; aniImageView=0; } -(void)didclick0:(UIButton *)sender{} -(void)createbgview { UIImageView *titleimageview=[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 320, 49)]; titleimageview.image=[UIImage imageNamed:@"2.png"]; [self.view addSubview:titleimageview]; UIImageView *bgimageview=[[UIImageView alloc]initWithFrame:CGRectMake(0, 44, 320, 418)]; bgimageview.image=[UIImage imageNamed:@"beijing"]; [self.view addSubview:bgimageview]; UIImage *image0=[UIImage imageNamed:@"1.png"]; UIImageView *footerimageview=[[UIImageView alloc]initWithFrame:CGRectMake(0,self.view.frame.size.height-49, 320, 49)]; footerimageview.image=image0; [self.view addSubview:footerimageview]; }
标签:style blog http color os 2014
原文地址:http://www.cnblogs.com/sunxiang1991/p/3850138.html