IOS 標籤按鈕的選擇

來源:互聯網
上載者:User

標籤:ios

typedef enum : NSUInteger {        FLSearchLabelButInformation = 1000, //資訊    FLSearchLabelButBBs = 1001,  //論壇    FLSearchLabelButMall = 1002,  //商城    FLSearchLabelButMobile = 1003, //手機    } FLSearchLabelBut;- (void)creatleUI{    NSArray *dataArry = @[@"諮詢", @"論壇", @"商城", @"手機"];        CGFloat deli_with = 50;    for (int index = 0; index < dataArry.count; index++) {                UIButton *butt = [UIButton buttonWithType:UIButtonTypeCustom];        butt.frame = CGRectMake(deli_with *index, 0, deli_with, CGRectGetHeight(self.frame));        butt.tag = FLSearchLabelButInformation + index;        [butt setTitleColor:[UIColor colorWithString:@"#969696"] forState:UIControlStateNormal];        if(index==0){            [butt setTitleColor:[UIColor colorWithString:@"#262626"] forState:UIControlStateNormal];        }        [butt setTitle:dataArry[index] forState:UIControlStateNormal];        butt.titleLabel.font = [UIFont systemFontOfSize:14.0f];        [butt addTarget:self action:@selector(onClickView:) forControlEvents:UIControlEventTouchUpInside];        [self addSubview:butt];    }}- (void)onClickView:(UIButton *)sender{      for(UIView *locateView in self.subviews){        if([locateView isKindOfClass:[UIButton class]]){            UIButton *locateButt = (UIButton *)locateView;            [locateButt setTitleColor:[UIColor colorWithString:@"#969696"] forState:UIControlStateNormal];        }    }    [sender setTitleColor:[UIColor colorWithString:@"#262626"] forState:UIControlStateNormal];        if([_delegate respondsToSelector:@selector(onClickSearhbutt:)]){        [_delegate onClickSearhbutt:sender.tag];    }}

650) this.width=650;" src="http://s4.51cto.com/wyfs02/M01/88/9D/wKiom1f83KXimJhIAAAlWe6Ru88538.png-wh_500x0-wm_3-wmp_4-s_141630130.png" title="239E130F-BA11-4E6A-9BEA-7E43BF55BB9D.png" style="float:left;" alt="wKiom1f83KXimJhIAAAlWe6Ru88538.png-wh_50" />

點擊每個標籤改變當前的顏色

本文出自 “雪花飛落滿人間” 部落格,請務必保留此出處http://smengxiang.blog.51cto.com/11204872/1860831

IOS 標籤按鈕的選擇

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.