zoukankan      html  css  js  c++  java
  • UIToolbar

    - (void)viewDidLoad {
      [super viewDidLoad];
      [self AddToolBars];

    }

    -(void)AddToolBars
    {
    UIToolbar *toolBarTop=[[UIToolbar alloc]initWithFrame:CGRectMake(0, 0, [[UIScreen mainScreen] bounds].size.width, 50)];
    [toolBarTop setBarStyle:UIBarStyleDefault];
    [self.view addSubview:toolBarTop];
    [toolBarTop setBarTintColor:[UIColor redColor]];

    UIBarButtonItem *item1=[[UIBarButtonItem alloc] initWithTitle:@"Add" style:UIBarButtonItemStyleDone target:self action:@selector(toolBarItemCilck)];
    item1.width=20;

    UIBarButtonItem *item2=[[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStyleDone target:self action:@selector(toolBarItemCilck)];
    item2.width=20;

    UIBarButtonItem *item4=[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:nil];
    item2.width=20;


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

    ToolBarItem *textField=[[ToolBarItem alloc] init];//自定义的UIview
    textField.frame=CGRectMake(0, 0, 200, 30);
    [textField.button addTarget:self action:@selector(btnClick1) forControlEvents:UIControlEventTouchUpInside];

    UIBarButtonItem *item5=[[UIBarButtonItem alloc]initWithCustomView:textField];//自定义的Item


    [toolBarTop setItems:[NSArray arrayWithObjects:item1,item5,nil] animated:YES];

    }

    @interface ToolBarItem : UIView

    -(id)init
    {
    self= [super init];
    _button=[[UIButton alloc] initWithFrame:CGRectMake(70, 0, 30, 30)];
    [_button setTitle:@"Click" forState:UIControlStateNormal];
    _button.backgroundColor=[UIColor grayColor];

    UITextField *t1=[[UITextField alloc]initWithFrame:CGRectMake(0, 0, 60, 30)];
    t1.placeholder=@"Hello";
    t1.backgroundColor=[UIColor orangeColor];

    [self addSubview:t1];
    [self addSubview:_button];

    return self;
    }

  • 相关阅读:
    03JavaScript程序设计修炼之道 2019-06-23_14-32-17
    03JavaScript程序设计修炼之道 2019-06-20_21-30-17
    03JavaScript程序设计修炼之道 2019-06-20_21-12-16
    03JavaScript程序设计修炼之道 2019-06-20_20-51-20
    03JavaScript程序设计修炼之道-2019-06-20_20-31-49
    03JavaScript程序设计修炼之道-2019-06-20_20-07-53
    02-CSS基础与进阶-day15
    02-CSS基础与进阶-day14
    02-CSS基础与进阶-day13_2018-09-21-21-13-20
    python基础(6)集合
  • 原文地址:https://www.cnblogs.com/zhangleixy/p/4975889.html
Copyright © 2011-2022 走看看