首页 > 代码库 > 自定义的UITabbar上面的按钮的x坐标的计算方法

自定义的UITabbar上面的按钮的x坐标的计算方法

 for (int i = 0; i < 4; i++) {//4是按钮的个数
        NSString *backImage = backgroud[i];
        NSString *heightImage = heightBackground[i];
        
        UIButton *button = [UIFactory createButton:backImage highlighted:heightImage];
        button.showsTouchWhenHighlighted = YES;
        button.frame = CGRectMake(320/ 4 * i + 25, (49-30)/2, 30, 30);//4是按钮的个数;25是自己不断修改得来的.
        [button addTarget:self action:@selector(selectedTab:) forControlEvents:UIControlEventTouchUpInside];
        [_tabbarView addSubview:button];
    }

效果如图: