关闭

类似POPView菜单

132人阅读 评论(0) 收藏 举报
分类:
-(void)btnClick:(UIButton *)button{
    if (self.btnStatus == YES) {
        [self.btn setImage:self.btnImageOff forState:UIControlStateNormal];
        [self addFenleiController];
        _fenleiController.view.hidden=NO;
    }
    else{
        [self.btn setImage:self.btnImageOn forState:UIControlStateNormal];
        
        _fenleiController.view.hidden = YES;
    }
    self.btnStatus = !self.btnStatus;
 
}
-(void)addFenleiController{
    _fenleiController =[[FenleiViewController alloc]init];
    _fenleiController.view.backgroundColor=[UIColor whiteColor];
    _fenleiController.view.frame =CGRectMake(0, 105, self.view.frame.size.width, 300);
    [_fenleiController willMoveToParentViewController:self];
    [self addChildViewController:_fenleiController];
    [self.view addSubview:_fenleiController.view];
    [_fenleiController didMoveToParentViewController:self];
    float length =(_fenleiController.view.frame.size.width-10)/4;
    NSArray *arr =@[@"巧手搭配",@"趣致创意",@"收纳控",@"食色",@"绿植",@"萌宠",@"生活杂事",@"DIY",@"相夫教子",@"别人的生活",@"洗刷刷",@"晒物",@"求助&经验"];
    for (int i=0; i<4; i++) {
        for (int j=0;j<4 ; j++) {
            UIButton *button=[UIButton buttonWithType:UIButtonTypeSystem];
            button.frame=CGRectMake(j*length+10, i*50+30, length-10, 30);
            button.backgroundColor =[UIColor groupTableViewBackgroundColor];
            [button setTitle:arr[i*4+j] forState:UIControlStateNormal];
            [button addTarget:self action:@selector(buttonClick1:) forControlEvents:UIControlEventTouchUpInside];
            button.tag =101+(i*4+j+2);
            [_fenleiController.view addSubview:button];
            if (j==0&&i==3) {
                
                return;
            }
        }
    }
}

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:27111次
    • 积分:507
    • 等级:
    • 排名:千里之外
    • 原创:9篇
    • 转载:95篇
    • 译文:0篇
    • 评论:0条
    文章分类