zoukankan      html  css  js  c++  java
  • UIToolbar自定义背景及按钮设置

     
    
      //1.创建toolbar(MyToolbar继承UIToolbar)
        _myToolbar = [[MyToolbar alloc]initWithFrame:CGRectMake(kZero, kZero, kScreenW, kToolbarH)];
        _myToolbar.backgroundColor = [ColorTools toolbarColor];
        
        //2.创建左右两边的buttonItem
        _leftButton = [[UIButton alloc]initWithFrame:CGRectMake(20, 35, 20, 20)];
        [_leftButton setImage:[UIImage imageNamed:@"left"] forState:UIControlStateNormal];
        [_leftButton setImage:[UIImage imageNamed:@"left_Highlight"] forState:UIControlStateHighlighted];
        [_leftButton addTarget:self action:@selector(left) forControlEvents:UIControlEventTouchUpInside];
        
        _rightButton = [[UIButton alloc]initWithFrame:CGRectMake(280, 35, 20, 20)];
        [_rightButton setImage:[UIImage imageNamed:@"right"] forState:UIControlStateNormal];
        [_rightButton setImage:[UIImage imageNamed:@"right_Highlight"] forState:UIControlStateHighlighted];
        [_rightButton addTarget:self action:@selector(right) forControlEvents:UIControlEventTouchUpInside];
        
        //3.创建中间的label
        _titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(125, kStatusH, 70, 44)];
        _titleLabel.text = @"测试Toolbar";
        _titleLabel.textColor = [UIColor whiteColor];
        
        //4.添加到当前视图中
        [_myToolbar addSubview:_titleLabel];
        [_myToolbar addSubview:_leftButton];
        [_myToolbar addSubview:_rightButton];
        [self.view addSubview:_myToolbar];
  • 相关阅读:
    初学Cocos2dx
    炸弹人NABCD分析
    求二维整数数组中最大联通子数组的和
    大道之简读书笔记1
    求首位相连二维数组最大子矩阵的和
    求首位相连一维数组最大子数组的和
    求二维数组最大子数组的和
    程序员修炼之道读后感3
    电梯调度需求分析
    课堂作业第四周课上作业二
  • 原文地址:https://www.cnblogs.com/hw140430/p/3713431.html
Copyright © 2011-2022 走看看