iOS基礎-UItoolBar簡單使用

來源:互聯網
上載者:User

標籤:

自訂工具列

 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];

 

iOS基礎-UItoolBar簡單使用

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.