zoukankan      html  css  js  c++  java
  • iOS基础-UItoolBar简单使用

    自定义如图工具栏

     1     //创建工具栏
     2     NSMutableArray *items = [[NSMutableArray alloc] initWithCapacity:3];
     3     UIBarButtonItem *confirmBtn = [[UIBarButtonItem alloc] initWithTitle:@"确定" style:UIBarButtonItemStyleDone target:self action:@selector(confirmPickView)];
     4     UIBarButtonItem *flexibleSpaceItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
     5     
     6     titleItem = [[UIBarButtonItem alloc] initWithTitle:@"用户类型" style:UIBarButtonItemStylePlain target:nil action:nil];
     7     
     8     //titleItem.tintColor = [UIColor blackColor];
     9     //titleItem.appearance.tintColor = [UIColor redColor];
    10     
    11     [titleItem setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor blackColor],UITextAttributeTextColor,[UIColor clearColor],UITextAttributeTextShadowColor, nil] forState:UIControlStateNormal];
    12 //
    13 //    [titleItem setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor blackColor],UITextAttributeTextColor,[UIColor clearColor],UITextAttributeTextShadowColor, nil] forState:UIControlStateDisabled];
    14     
    15     titleItem.enabled = NO;
    16     titleItem.tag = 1;
    17     
    18     UIBarButtonItem *cancelBtn = [[UIBarButtonItem alloc] initWithTitle:@"取消" style:UIBarButtonItemStyleBordered target:self action:@selector(pickerHide)];
    19     [items addObject:cancelBtn];
    20     [items addObject:flexibleSpaceItem];
    21     [items addObject:titleItem];
    22     [items addObject:flexibleSpaceItem];
    23     [items addObject:confirmBtn];
    24     
    25     if (toolBar==nil) {
    26         toolBar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, self.view.frame.size.height, 320, 44)];
    27         [toolBar setBackgroundImage:[UIImage imageNamed:@"search_buttom"] forToolbarPosition:0 barMetrics:0];
    28     }
    29     //toolBar.hidden = YES;
    30     
    31     toolBar.barStyle = UIBarStyleBlackTranslucent;
    32     toolBar.items = items;
    33     [self.view addSubview:toolBar];
  • 相关阅读:
    浮点数大于0
    坐标变换
    实战c++中的vector系列--正确释放vector的内存(clear(), swap(), shrink_to_fit())
    计算sigma
    ECharts 在winform中使用(访问JS)
    Linux用户锁定、解锁及锁定查看
    vue或者js中平均分割数组
    python 文件读写with open模式r,r+,w,w+,a,a+的区别
    vue 三元表达式当出现elif
    后端排序时去掉element表格排序的null状态
  • 原文地址:https://www.cnblogs.com/dingjianjaja/p/5026756.html
Copyright © 2011-2022 走看看