藍懿IOSUI新框件UISegmentControl

來源:互聯網
上載者:User

標籤:

今天又學習了好多新的UI類框件,UISegmentedControl,UIStepper,還有Unbutton的新的功能當使用者輸入不僅僅是布爾值時,可使用分段控制項(UISegmentedControl)。分段控制項提供一欄按鈕(有時稱為按鈕欄),但只能啟用其中一個按鈕。分段控制項會導致使用者在螢幕上看到的內容發生變化。它們常用於在不同類別的資訊之間選擇,或在不同的應用螢幕之間切換。

 NSArray *[email protected][@"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(20, 20, 100, 30)];

    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];

}

 分享到:

藍懿IOSUI新框件UISegmentControl

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.