分段

#import "XLSlideSwitch.h"
#import "RDViewController.h"
#import "TJViewController.h"
#import "YLViewController.h"
#import "SPViewController.h"
#import "DYViewController.h"
#import "SJViewController.h"
@interface oneViewController (){
    UIView  * Someview;   //是点击加号的按钮
}
@property(nonatomic,strong)XLSlideSwitch *  GDview; // 滚动视图

@end

@implementation oneViewController


- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title =  @"首页";
    //    self.navigationController.navigationBar.barTintColor = [UIColor whiteColor];
    //分段控制器
    //创建一个数组
    NSArray  * arr =@[@"推荐",@"热点",@"娱乐",@"视频",@"订阅",@"事件"];
   
    //数组
    NSArray  * array =@[@"RDViewController",@"TJViewController",@"YLViewController",@"SPViewController",@"DYViewController",@"SJViewController"];
   
    //可变数组
   
    NSMutableArray   *  viewcontroller = [[NSMutableArray alloc] init];
   
    //创建一个for循环
    for(int  i = 0; i        //字符串控制器
        UIViewController  *  VC = [[NSClassFromString(array[i])alloc] init];
        //添加
        [viewcontroller   addObject:VC];
    }
    //滚动视图
    _GDview  = [[XLSlideSwitch alloc] initWithFrame:CGRectMake(0, 64, self.view.bounds.size.width, self.view.bounds.size.height - 64) Titles:arr viewControllers:viewcontroller];
    //代理
    _GDview.delegate=self;
   
    //颜色
    _GDview.itemNormalColor=[UIColor darkGrayColor];
   
    _GDview.itemSelectedColor = self.navigationController.navigationBar.tintColor;
    //设置控件的距离
    _GDview.customTitleSpacing = 30;
   
    [_GDview showInViewController:self];
   
   
    Someview = [[UIView alloc] initWithFrame:CGRectMake(self.view.bounds.size.width - 150, 104, 140, 200)]; Someview.backgroundColor = [UIColor orangeColor];
    for (int i = 0 ; i < 1; i ++) { [self.view addSubview:Someview];
       
        Someview.backgroundColor = [UIColor orangeColor];
       
        for (int i = 0 ; i < 1; i ++) {
            [self.view addSubview:Someview];
            Someview.hidden = YES;
        }
       
    }
   
   
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

你可能感兴趣的:(分段)