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];
  • 相关阅读:
    2017-2018-1 20155334第八周课堂实践总结+课下作业+教材内容总结
    移动手机号段区别
    使用Maven搭建Hadoop开发环境
    RunMR.java
    BeanUtils内省工具包
    eclipse和myeclipse中如何关闭自动补全括号,花括号,双引号等功能
    为什么在jsp中写${pageContext.request.contextPath }失效了
    开发WEB项目的步骤
    MVC的职责分工
    关于import中使用*号是否会影响程序性能
  • 原文地址:https://www.cnblogs.com/dingjianjaja/p/5026756.html
Copyright © 2011-2022 走看看