• 导航控制器




    #import "ViewController.h" #import "SecondViewController.h" @interface ViewController () @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; UIImageView *imageview=[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 320, 480)]; UIImage *image=[UIImage imageNamed:@"bg_01.png"]; imageview.image=image; [self.view addSubview:imageview]; UIImageView *imagview=[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 320, 480)]; UIImage *imag=[UIImage imageNamed:@"bg_01_01.png"]; imagview.image=imag; [self.view addSubview:imagview]; UIButton *backbutton=[UIButton buttonWithType:UIButtonTypeCustom]; backbutton.frame=CGRectMake(70,45,36, 32); [backbutton addTarget:self action:@selector(click1:) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:backbutton]; // Do any additional setup after loading the view, typically from a nib. } -(void)click1:(UIButton *)sender{ NSLog(@"%s", __PRETTY_FUNCTION__); SecondViewController *secondCtrl = [[SecondViewController alloc] init]; secondCtrl.title = @"Second"; secondCtrl.url = [[NSBundle mainBundle] URLForResource: @"000_a" withExtension:@"mp3"]; [self.navigationController pushViewController:secondCtrl animated:YES]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } @end
    #import "SecondViewController.h"
    #import <AudioToolbox/AudioToolbox.h>
    
    @interface SecondViewController ()
    @end
    
    @implementation SecondViewController{
    UIImageView *aniImageView;
       SystemSoundID soundID;
    }
    
    - (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
    {
        self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
        if (self) {
            // Custom initialization
        }
        return self;
    }
    
    
    -(void)creatview{
        UIImageView *backview=[[UIImageView alloc] initWithFrame:CGRectMake(0, 44, 320, 418)];
        backview.image=[UIImage imageNamed:@"kanaDetailBgImg"];
        [self.view addSubview:backview];
        
        
        UIImageView *startview=[[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 49)];
        startview.image=[UIImage imageNamed:@"titleView"];
        [self.view addSubview:startview];
        
        UIImageView *endview=[[UIImageView alloc] initWithFrame:CGRectMake(0, self.view.frame.size.height-49, 320, 52)];
        endview.image=[UIImage imageNamed:@"bottomBg"];
        [self.view addSubview:endview];
        
        
        
        
    }
    -(void)button{
        UIButton *backbutton=[UIButton buttonWithType:UIButtonTypeCustom];
        [backbutton setImage:[UIImage imageNamed:@"backBtn"] forState:UIControlStateNormal];
        backbutton.frame=CGRectMake(10, 6, 70, 35);
        [backbutton addTarget:self action:@selector(click1:) forControlEvents:UIControlEventTouchUpInside];
        [self.view addSubview:backbutton];
        
        //3. 下面的按钮
        UIButton *voiceBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        voiceBtn.frame = CGRectMake(10, self.view.frame.size.height - 52, 67, 52);
        [voiceBtn setImage:[UIImage imageNamed:@"pronounceBtn_01"] forState:UIControlStateNormal];
        //按钮按下去是高亮状态
        [voiceBtn setImage:[UIImage imageNamed:@"pronounceBtn_02"] forState:UIControlStateHighlighted];
        [voiceBtn addTarget:self action:@selector(Play:) forControlEvents:UIControlEventTouchUpInside];
        [self.view addSubview:voiceBtn];
        
        
        
    }
    -(void)button1{
        //   NSLog(@"%s", __PRETTY_FUNCTION__);
        
        //
        UIButton *bakbutton=[UIButton buttonWithType:UIButtonTypeCustom];
        bakbutton.frame=CGRectMake(100, 6, 70, 35);
        [bakbutton setImage:[UIImage imageNamed:@"practiceBtn"] forState:UIControlStateNormal];
        
        [bakbutton addTarget:self action:@selector(animation) forControlEvents:UIControlEventTouchUpInside];
        [self.view addSubview:bakbutton];
        
        
        
    }
    -(void)animation{
        int i=1;
        aniImageView=[[UIImageView alloc]initWithFrame:CGRectMake(45, 75, 255, 255)];
        NSMutableArray *array=[[NSMutableArray alloc] init];
        for (i=1; i<=11; i++) {
            NSString *name=[NSString stringWithFormat:@"wo%04d", i];
            
            NSLog(@"%@", name);
            UIImage *image = [UIImage imageNamed:name];
            [array addObject:image];
        }
        aniImageView.animationImages = array;
        [self.view addSubview:aniImageView];
        aniImageView.animationDuration=5;
        aniImageView.animationRepeatCount = 1;
        aniImageView.animationImages = array; //跳动的图片
        [aniImageView startAnimating]; //调用方法
        [self.view addSubview:aniImageView];
    }
    
    - (void)click1:(UIButton *)sender
    {
        
        SecondViewController *secondcontor=[[SecondViewController alloc]init];
        secondcontor.view.backgroundColor  =[UIColor greenColor];
        
        
        [self.navigationController pushViewController:secondcontor animated:YES];
        NSLog(@"%s", __PRETTY_FUNCTION__);
    }
    
    
    
    - (void)Play:(UIButton *)sender
    {
        NSLog(@"aaaaa%s", __PRETTY_FUNCTION__);
          AudioServicesCreateSystemSoundID((__bridge CFURLRef)(_url), &soundID);
        AudioServicesPlaySystemSound(soundID);
    
    }
    - (void)viewDidLoad {
        [super viewDidLoad];
        [self creatview];
        [self button];
        [self button1];
        UIImageView *imageview=[[UIImageView alloc]initWithFrame:CGRectMake(45, 75, 255, 255)];
        UIImage *image=[UIImage imageNamed:@"u0011.png"];
        imageview.image=image;
        [self.view addSubview:imageview];
        self.navigationController.navigationBarHidden=YES;
        
        NSURL *url = [[NSBundle mainBundle] URLForResource:@"000_a" withExtension:@"mp3"];
        AudioServicesCreateSystemSoundID((__bridge CFURLRef)(url), &soundID);
        
        //NSURL *url = [NSBundle mainBundle] URLForResource:@"124-do" withExtension:@"mp3"
        
        // Do any additional setup after loading the view, typically from a nib.
    }
    
    - (void)didReceiveMemoryWarning
    {
        [super didReceiveMemoryWarning];
        // Dispose of any resources that can be recreated.
    }
    
    /*
    #pragma mark - Navigation
    
    // In a storyboard-based application, you will often want to do a little preparation before navigation
    - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
    {
        // Get the new view controller using [segue destinationViewController].
        // Pass the selected object to the new view controller.
    }
    */
    
    @end
    
  • 相关阅读:
    第二十三篇 jQuery 学习5 添加元素
    第二十二篇 jQuery 学习4 内容和属性
    第二十一篇 jQuery 学习3 特效效果
    第二十篇 jQuery 初步学习2
    第十九篇 jQuery初步学习
    第十八篇 JS传参数
    第十七篇 JS验证form表单
    第十六篇 JS实现全选操作
    第十五篇 JS 移入移出事件 模拟一个二级菜单
    第十四篇 JS实现加减乘除 正则表达式
  • 原文地址:https://www.cnblogs.com/changfei/p/3849919.html
Copyright © 2020-2023  润新知