转载iOS DeveloperiOS第三方资料收集

快速创建类似某宝店铺详情页、随意添加删除子控制器

2017-01-14  本文已影响73人  一块豆腐

最近项目需要一个类似淘宝店铺详情页的界面,实现完需求闲着没事就简单封装一下SBHeaderTitleController

用法 继承SBHeaderTitleController 用法和系统的UITabBarController 差不多

- (void)viewDidLoad {
    [super viewDidLoad];
    //添加所有的控制器
    [self setupAllChildVc];
    UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 0, 100)];
    imageView.contentMode = UIViewContentModeScaleToFill;
    imageView.image = [UIImage imageNamed:@"taobao"];
    
    self.headerView = imageView;
    self.headerViewStyle = SBHeaderViewStyleBottom;
}

- (void)setupAllChildVc
{
    
    UIViewController *first = [[FirstTableViewController alloc] init];
    first.title = @"首页";
    [self addChildViewController:first];

    UIViewController *second = [[SecondTableViewController alloc] init];
    second.title = @"全部商品";
    [self addChildViewController:second];
    
    UIViewController *third = [[ThirdTableViewController alloc] init];
    third.title = @"上新";
    [self addChildViewController:third];
    
    UIViewController *fourth = [[ThirdTableViewController alloc] init];
    fourth.title = @"全部商品";
    [self addChildViewController:fourth];
    
}
某宝.gif
上一篇 下一篇

猜你喜欢

热点阅读