iOS 在一个屏幕中根据不同的按钮创建不同的 view 默认显示第一个

哪哥  我的默认显示 第一个怎么办呢  现在创建完视图 但是创建之后默认显示第一个怎么做啊

#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;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值