• 2016-01-07 UIToolbar


    //

    //  GZToolbarViewController.m

    //  toolbar

    //

    //  Created by Apple on 16/1/7.

    //  Copyright © 2016 ShangYu. All rights reserved.

    //

     

    #import "GZToolbarViewController.h"

     

    @interface GZToolbarViewController ()

     

    @end

    #define SCREENW [UIScreen mainScreen].bounds.size.width

    #define SCREENH [UIScreen mainScreen].bounds.size.height

    @implementation GZToolbarViewController

     

    - (void)viewDidLoad {

        [super viewDidLoad];

        

        self.view.backgroundColor=[UIColor whiteColor];

    //

        self.title=@"toolBar";

    //    UIToolbar *toolBar=[[ UIToolbar alloc ] initWithFrame : CGRectMake ( 0 , self.view.frame.size.height - 44 , self.view.frame.size.width/2 , 44 )];

        UIToolbar *toolBar=[[ UIToolbar alloc ] initWithFrame : CGRectMake ( 0, self.view.frame.size.height - 44 , 30 , 44 )];

     

    //    toolBar. barStyle = UIBarButtonItemStylePlain ;

    //    toolBar.barStyle=UIBarStyleBlackOpaque;

        toolBar.backgroundColor=[UIColor clearColor];

        [ self . view addSubview :toolBar];

     

        UIBarButtonItem *sapce=[[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:self action:nil];

        sapce.width=-15;

        

        

        UIButton  *yellowBtn=[[UIButton alloc]initWithFrame:CGRectMake(0, 0, SCREENW/2, 44)];

        yellowBtn.backgroundColor=[UIColor blueColor];

        [yellowBtn addTarget:self action:@selector(yellowCkick) forControlEvents:UIControlEventTouchUpInside];

        UIBarButtonItem *addItem=[[UIBarButtonItem alloc]initWithCustomView:yellowBtn];

        

        

        UIBarButtonItem *sapce1=[[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:self action:nil];

        sapce1.width=-10;

        

        UIButton  *redBtn=[[UIButton alloc]initWithFrame:CGRectMake(SCREENW/2, 0, SCREENW/2, 44)];

        redBtn.backgroundColor=[UIColor redColor];

        [redBtn addTarget:self action:@selector(redClick) forControlEvents:UIControlEventTouchUpInside];

     

        UIBarButtonItem *jianItem=[[UIBarButtonItem alloc]initWithCustomView:redBtn];

        

         NSArray *items=[ NSArray arrayWithObjects :sapce,addItem,sapce1,jianItem,

                         nil ];

        toolBar.items=items;

     

        [toolBar sizeToFit];

        

        

        

        

        

    //

    //    UIButton  *yellowBtn=[[UIButton alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width/2, 44)];

    //    yellowBtn.backgroundColor=[UIColor yellowColor];

    // 

    //    UIBarButtonItem *addItem=[[UIBarButtonItem alloc]initWithCustomView:yellowBtn];

    //    

    //    

    ////    UIBarButtonItem *Item=[[ UIBarButtonItem alloc ] initWithBarButtonSystemItem : UIBarButtonSystemItemFlexibleSpace target : self action : nil ];

    ////    Item.width=0;

    //    

    //    

    //    UIButton  *redBtn=[[UIButton alloc]initWithFrame:CGRectMake(self.view.frame.size.width/2, 0, self.view.frame.size.width/2, 44)];

    //    redBtn.backgroundColor=[UIColor redColor];

    //    

    //    UIBarButtonItem *editItem=[[ UIBarButtonItem alloc ]initWithCustomView:redBtn];

    //    

    //    NSArray *items=[ NSArray arrayWithObjects :addItem,editItem, nil ];

    //    

    //    [ self setToolbarItems :items];  //UIToolBar添加UIBarButtonItem

    //    [ self . navigationController setToolbarHidden : NO animated : NO ];

        

     

     

    }

     

    -(void)yellowCkick{

        NSLog(@"yellow");

    }

    -(void)redClick{

     

        NSLog(@"red");

    }

     

    - (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

  • 相关阅读:
    java算法
    2012 要找回曾经的忘我的激情
    啊啊啊
    利用ORACLE JOB 模拟多线程应用
    有没有一种数据库叫思科
    且行好事,莫问前程
    女人浪漫的好点子
    What is the difference between interface and abstract class
    优秀是一种习惯
    C#判断ContextMenuStrip右键菜单的来源(从哪个控件弹出来的) (转载)
  • 原文地址:https://www.cnblogs.com/gzz2016/p/5110689.html
Copyright © 2020-2023  润新知