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];
  • 相关阅读:
    安装httpd服务
    tmpfs临时文件系统,是一种基于内存的文件系统
    oracle Awr报告
    maven jar 怎么看jdk编译版本
    Oracle 11g direct path read 等待事件的理解
    Spring AOP 实现原理
    JVM相关知识(1)
    spring ioc原理(看完后大家可以自己写一个spring)
    java中HashSet详解
    java中HashMap详解
  • 原文地址:https://www.cnblogs.com/dingjianjaja/p/5026756.html
Copyright © 2011-2022 走看看