zoukankan      html  css  js  c++  java
  • 被忽视的控件UIToolbar

    前言

    UIToolbar以前也接触过,不过没有怎么用,久而久之就忘了他的存在,今天看别人源码的时候看见了,它怎么很方便,在排列一排视图的时候不需要我们算里面的坐标就可以轻松良好的把布局做出来

    代码

        UIToolbar *tool = [[UIToolbar alloc]initWithFrame:CGRectMake(0, 100, 300, 50)];
        tool.layer.borderWidth = 1;
        tool.barStyle = UIBarStyleBlack;
        tool.backgroundColor = [UIColor blackColor];
        [self.view addSubview:tool];
        
        
        //中间空余部分
        UIBarButtonItem *space = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:NULL];
        
          UIBarButtonItem *previousItem = [[UIBarButtonItem alloc]initWithImage:[[UIImage imageNamed:@"player_pause"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] style:UIBarButtonItemStyleDone target:self action:@selector(previous:)];
        UIBarButtonItem *previousItem1 = [[UIBarButtonItem alloc]initWithImage:[[UIImage imageNamed:@"player_pause"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] style:UIBarButtonItemStyleDone target:self action:@selector(previous:)];
        UISlider *slider = [[UISlider alloc]initWithFrame:CGRectMake(0, 0, 150, 20)];
        UIBarButtonItem *volumnItem = [[UIBarButtonItem alloc]initWithCustomView:slider];
        
        tool.items = @[space,previousItem1,space,volumnItem,space,previousItem];

    效果图

  • 相关阅读:
    find和findIndex原理
    npm相关依赖操作+版本问题
    package-lock锁文件作用
    npm的版本控制和切换
    package.json文件各个选项含义
    package.json中的script选项作用
    WPF学习之资源-Resources
    WPF中的ListBox实现按块显示元素的方法
    WPF中button按钮同时点击多次触发click解决方法
    浅谈WPF本质中的数据和行为
  • 原文地址:https://www.cnblogs.com/hxwj/p/5231178.html
Copyright © 2011-2022 走看看