当前位置:首页 > 操作系统 > Ios

蓝懿IOSUI新框件UISegmentControl

今天又学习了好多新的UI类框件,UISegmentedControl,UIStepper,还有Unbutton的新的功能 当用户输入不仅仅是布尔值时,可使用分段控件(UISegmentedControl)。分段控件提供一栏按钮(有时称为按钮栏),但只能激活其中一个按钮。分段控件会导致用户在屏幕上看到的内容发生变化。它们常用于在不同类别的信息之间选择,或在不同的应用屏幕之间切换。

  NSArray  *arry= @[@"first",@"第二",@"3nn"];

    //self.segment=[[UISegmentedControl alloc]initWithFrame:CGRectMake(200, 200, 100, 100)];

     self . segment =[[UISegmentedControl alloc]initWithItems:arry];

     // 设置成YES,点击后,颜色闪一次,之后不会变

     self . segment .momentary=NO;

    [ self . segment  addTarget:self action:@selector(mpp) forControlEvents:UIControlEventValueChanged];

    

    [self.view addSubview:self.segment];

}

-(void)moo{

     NSLog ( @"%lu" , self . segment .numberOfSegments);

     self . segment .tintColor=[UIColor redColor];

     NSLog ( @"%lu" , self . segment .selectedSegmentIndex);

    [ self . segment  insertSegmentWithTitle:@"呵呵" atIndex:1 animated:YES];

    [ self . segment  removeSegmentAtIndex:0 animated:YES];

    NSLog(@"%@",[self.segment titleForSegmentAtIndex:2]);

self . stepper =[[ UIStepper  alloc]initWithFrame:CGRectMake(202010030)];

     self . stepper .minimumValue=1;

     self . stepper .maximumValue=20;

     self . stepper . stepValue = 1 ;//  步进值,每次点击变化1

    // YES 点击控件不松开方法一直执行NSLog有输出,NO 点击不松开方法一直执行,但是NSLog不输出

     //  self.stepper.continuous=YES;

    self . stepper . autorepeat = NO // YES 点击控件不松开方法一直在执行,NSLog有输出.NO 点击不松开方法治执行一次,//点击一次执行一次。

    [ self . stepper  setBackgroundImage:[UIImage imageNamed:@"Red1 Circle"forState:UIControlStateNormal];

}


【说明】本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!