导航分段控制器

1.导入第三方XHSegmentController
2.创建继承SegmentSampleViewController的文件
3.在App.m中

#import "AppDelegate.h"
#import "SegmentSampleViewController.h"

@interface AppDelegate ()

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    SegmentSampleViewController *vc = [[SegmentSampleViewController alloc] init];
    self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
    self.window.rootViewController = vc;
    [self.window makeKeyAndVisible];
    return YES;
}

4.v.m中写控制器背景颜色

[self.view setBackgroundColor:[UIColor whiteColor]];

5.创建3个继承ViewController
6.在SegmentSampleViewController.h中


#import <UIKit/UIKit.h>
#import "XHSegmentViewController.h"

@interface SegmentSampleViewController : XHSegmentViewController

@end

.m中

#import "SegmentSampleViewController.h"
#import "ViewController.h"
#import "oneViewController.h"
#import "twoViewController.h"
@interface SegmentSampleViewController ()

@end

@implementation SegmentSampleViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    ViewController *vc1 = [[ViewController alloc] init];
    vc1.title = @"男装";
    
    oneViewController *vc2 = [[oneViewController alloc] init];
    vc2.title = @"女装";
    
    twoViewController *vc3 = [[twoViewController alloc] init];
    vc3.title = @"童装";
    
    self.viewControllers = @[vc1, vc2, vc3];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

@end
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值