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];
  • 相关阅读:
    进程间通讯----消息队列和共享内存方式的实现
    初探 Yii2 的测试模式 index-test.php
    nginx缓存功能的设置
    php五大运行模式CGI,FAST-CGI,CLI,ISAPI,APACHE模式
    workerman如何写mysql连接池
    Varnish 一般是放在 Nginx 前面还是后面的?
    关于PATH_INFO
    Java8 Lambda表达式
    synchronized的一些记录
    类和实例
  • 原文地址:https://www.cnblogs.com/hw140430/p/3713431.html
Copyright © 2011-2022 走看看