• 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调用wcf
    登录重构小记
    从零打造一个Web地图引擎
    Vue动态组件的实践与原理探究
    揭开Vue异步组件的神秘面纱
    使用vue实现排序算法演示动画
    C#转义字符
    asp.net使用post方式action到另一个页面,在另一个页面接受form表单的值!(报错,已解决!)
    页面关闭事件onbeforeunload 记录
    执行一段sql
  • 原文地址:https://www.cnblogs.com/gzz2016/p/5110689.html
Copyright © 2020-2023  润新知