UIControll控制器 復習

#import "RootViewController.h"

@interface RootViewController ()

@property (nonatomic, retain) UIView *redV;

@property (nonatomic, retain) UIView *greenV;

@end

@implementation RootViewController

- (void)viewDidLoad {

[super viewDidLoad];

// Do any additional setup after loading the view.

self.view.backgroundColor = [UIColor whiteColor];

//? 四種控制器

//1.SegmentedControl

//設置屬性

UISegmentedControl *seg = [[UISegmentedControl alloc]initWithItems:@[@"消息",@"聯(lián)系人",@"電話"]];

seg.frame = CGRectMake(100, 64, 175, 40);

seg.backgroundColor = [UIColor whiteColor];

[self.view addSubview:seg];

[seg release];

//當前的下角標

seg.selectedSegmentIndex = 2;

seg.tintColor = [UIColor grayColor];

[seg addTarget:self action:@selector(clickseg:) forControlEvents:UIControlEventValueChanged];

//設置了兩個頁面的屬性

//設置紅色小頁面的屬性

self.redV = [[UIView alloc]initWithFrame:CGRectMake(50, 464, 300, 200)];

self.redV.backgroundColor = [UIColor redColor];

[self.view addSubview:self.redV];

[self.redV release];

//設置一個綠色小頁面的屬性

self.greenV = [[UIView alloc]initWithFrame:CGRectMake(50, 464, 300, 200)];

self.greenV.backgroundColor = [UIColor greenColor];

[self.view addSubview:self.greenV];

[self.greenV release];

//2.開關控制器

UISwitch *swi = [[UISwitch alloc]initWithFrame:CGRectMake(100, 120, 50 , 50)];

swi.backgroundColor = [UIColor whiteColor];

[self.view addSubview:swi];

[swi release];

[swi addTarget:self action:@selector(clickswi:) forControlEvents:UIControlEventValueChanged];

//3.大小聲的控制器

UISlider *slider = [[UISlider alloc]initWithFrame:CGRectMake(50, 200, 100, 40)];

slider.backgroundColor = [UIColor yellowColor];

[self.view addSubview:slider];

[slider release];

//設置最大聲

slider.maximumValue = 1000;

slider.maximumTrackTintColor = [UIColor redColor];

//設置一下最小生

slider.minimumValue = 100;

slider.minimumTrackTintColor = [UIColor orangeColor];

[slider addTarget:self action:@selector(clickslider:) forControlEvents:UIControlEventValueChanged];

//小圓點控制器(最熟悉不過的了)

UIPageControl *pc = [[UIPageControl alloc]initWithFrame:CGRectMake(100, 300, 100, 50)];

pc.backgroundColor = [UIColor blackColor];

[self.view addSubview:pc];

[pc release];

pc.numberOfPages = 4;

pc.currentPage = 0;

pc.pageIndicatorTintColor = [UIColor orangeColor];

pc.currentPageIndicatorTintColor = [UIColor whiteColor];

[pc addTarget:self action:@selector(clickpc:) forControlEvents:UIControlEventValueChanged];

}

//開關控制器的方法

- (void)clickswi: (UISwitch *)swi

{

if (swi.on) {

NSLog(@"開啟");

} else {

NSLog(@"關閉");

}

}

//大小聲控制的方法

- (void)clickslider:(UISlider *)slider

{

NSLog(@"%f",slider.value);

}

//小圓點控制的方法

- (void) clickpc: (UIPageControl *)pc {

NSLog(@"%ld",pc.currentPage);

}

//分開頁面的控制器的方法

- (void)clickseg: (UISegmentedControl *)seg

{

//當控制器的索引值是0的時候出現(xiàn)的是綠色的小頁面

if (seg.selectedSegmentIndex == 0) {

[UIView transitionFromView:self.greenV toView:self.redV duration:1 options:UIViewAnimationOptionTransitionFlipFromBottom completion:^(BOOL finished) {

}];

}

//當控制器的索引值是1的時候出現(xiàn)的是紅色的小頁面

if (seg.selectedSegmentIndex == 1) {

[UIView transitionFromView:self.redV toView:self.greenV duration:1 options:UIViewAnimationOptionTransitionCurlUp completion:^(BOOL finished) {

}];

}

NSLog(@"%ld",seg.selectedSegmentIndex);

}

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市偎箫,隨后出現(xiàn)的幾起案子悼做,更是在濱河造成了極大的恐慌,老刑警劉巖缩抡,帶你破解...
    沈念sama閱讀 217,657評論 6 505
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場離奇詭異包颁,居然都是意外死亡瞻想,警方通過查閱死者的電腦和手機,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 92,889評論 3 394
  • 文/潘曉璐 我一進店門娩嚼,熙熙樓的掌柜王于貴愁眉苦臉地迎上來蘑险,“玉大人,你說我怎么就攤上這事岳悟〉杵” “怎么了泼差?”我有些...
    開封第一講書人閱讀 164,057評論 0 354
  • 文/不壞的土叔 我叫張陵,是天一觀的道長呵俏。 經(jīng)常有香客問我堆缘,道長,這世上最難降的妖魔是什么普碎? 我笑而不...
    開封第一講書人閱讀 58,509評論 1 293
  • 正文 為了忘掉前任吼肥,我火速辦了婚禮,結果婚禮上麻车,老公的妹妹穿的比我還像新娘缀皱。我一直安慰自己,他們只是感情好动猬,可當我...
    茶點故事閱讀 67,562評論 6 392
  • 文/花漫 我一把揭開白布啤斗。 她就那樣靜靜地躺著,像睡著了一般赁咙。 火紅的嫁衣襯著肌膚如雪钮莲。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 51,443評論 1 302
  • 那天彼水,我揣著相機與錄音臂痕,去河邊找鬼。 笑死猿涨,一個胖子當著我的面吹牛握童,可吹牛的內容都是我干的。 我是一名探鬼主播叛赚,決...
    沈念sama閱讀 40,251評論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼澡绩,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了俺附?” 一聲冷哼從身側響起肥卡,我...
    開封第一講書人閱讀 39,129評論 0 276
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎事镣,沒想到半個月后步鉴,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 45,561評論 1 314
  • 正文 獨居荒郊野嶺守林人離奇死亡璃哟,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內容為張勛視角 年9月15日...
    茶點故事閱讀 37,779評論 3 335
  • 正文 我和宋清朗相戀三年氛琢,在試婚紗的時候發(fā)現(xiàn)自己被綠了。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片随闪。...
    茶點故事閱讀 39,902評論 1 348
  • 序言:一個原本活蹦亂跳的男人離奇死亡阳似,死狀恐怖,靈堂內的尸體忽然破棺而出铐伴,到底是詐尸還是另有隱情撮奏,我是刑警寧澤俏讹,帶...
    沈念sama閱讀 35,621評論 5 345
  • 正文 年R本政府宣布,位于F島的核電站畜吊,受9級特大地震影響泽疆,放射性物質發(fā)生泄漏。R本人自食惡果不足惜玲献,卻給世界環(huán)境...
    茶點故事閱讀 41,220評論 3 328
  • 文/蒙蒙 一殉疼、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧青自,春花似錦株依、人聲如沸驱证。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,838評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽抹锄。三九已至逆瑞,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間伙单,已是汗流浹背获高。 一陣腳步聲響...
    開封第一講書人閱讀 32,971評論 1 269
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留吻育,地道東北人念秧。 一個月前我還...
    沈念sama閱讀 48,025評論 2 370
  • 正文 我出身青樓,卻偏偏與公主長得像布疼,于是被迫代替她去往敵國和親摊趾。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當晚...
    茶點故事閱讀 44,843評論 2 354

推薦閱讀更多精彩內容