哪哥 我的默认显示 第一个怎么办呢 现在创建完视图 但是创建之后默认显示第一个怎么做啊
#pragma mark - 初始化
- (void)initParamUI {
self.pMessageArray = @[@\"摇骰子\",@\"拼手气\",@\"稳准狠\"];
self.pTabIconSelectArray = @[@\"Line\",@\"Line\",@\"Line\"];
}
#pragma mark - 创建标签
- (void)createTally {
self.pDockView = [[XYView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, XYONDockHeight)];
self.pDockView.userInteractionEnabled = YES;
self.pDockView.backgroundColor =UIColorFromRGB(0xFCFCFC);
[[super pBgScrollView] addSubview:self.pDockView];
float pBtnWidth = SCREEN_WIDTH/3;
for (int i = 0; i < 3; i++) {
XYButton_Tabs *pBtn = [XYButton_Tabs buttonWithType:UIButtonTypeCustom];
pBtn.frame = CGRectMake(i*pBtnWidth, 0, pBtnWidth,XYONDockHeight);
pBtn.titleLabel.textAlignment = NSTextAlignmentCenter;
if (self.pTabIconSelectArray.count > 0) {
[pBtn setSelectImage:self.pTabIconSelectArray[i]];
}
[pBtn setBoldFontSize:XYFontSize];
[pBtn addClickTarget:self action:@selector(selectViewControl:)];
[pBtn setNormalTitle:self.pMessageArray[i]];
[pBtn setTitleColor:XYFontNormalColor forState:UIControlStateNormal];
[pBtn setTitleColor:XYFontSelectColor forState:UIControlStateSelected];
[pBtn setTag:XYBtnTag+i];
[self.pDockView addSubview:pBtn];
//默认显示
if(i == XYCheckNum){
[pBtn setSelected:YES];
[pBtn setBackgroundColor:XYBtnBackground];
[pBtn setUserInteractionEnabled:NO];
self.pCurrentBtn = pBtn;
}
}
}
#pragma mark 按钮点击事件
- (void)selectViewControl:(XYButton *)btn {
//改变按钮
[self changeTabBtnStyle:btn];
switch (btn.tag) {
case 888:
{
XYView *a = [XYView createViewWithRect:CGRectMake(0, XYONDockHeight, SCREEN_WIDTH, [super pBgScrollView].maxY - XYONDockHeight)];
a.backgroundColor = [UIColor yellowColor];
[[super pBgScrollView] addSubview:a];
}
break;
case 889:
{
XYView *b = [XYView createViewWithRect:CGRectMake(0, XYONDockHeight, SCREEN_WIDTH, [super pBgScrollView].maxY - XYONDockHeight)];
b.backgroundColor = [UIColor redColor];
[[super pBgScrollView] addSubview:b];
}
break;
case 890:
{
XYView *c = [XYView createViewWithRect:CGRectMake(0, XYONDockHeight, SCREEN_WIDTH, [super pBgScrollView].maxY - XYONDockHeight)];
c.backgroundColor = [UIColor blueColor];
[[super pBgScrollView] addSubview:c];
}
break;
default:
break;
}
}
#pragma mark 改变按钮样式
- (void)changeTabBtnStyle:(XYButton *)btn {
for (int i = 0; i < 3; i++) {
[[self.pDockView subviews][i] setBackgroundColor:CLEARCOLOR];
[[self.pDockView subviews][i] setSelected:NO];
}
btn.selected = YES;
btn.backgroundColor = XYBtnBackground;
btn.userInteractionEnabled = NO;
self.pCurrentBtn.userInteractionEnabled = YES;
self.pCurrentBtn = btn;
}
- 点赞
- 收藏
- 分享
- 文章举报
站内首发文章litiao9077发布了2 篇原创文章 · 获赞 0 · 访问量 102私信关注