Xcode控件使用筆記
label控件:
//4.1添加名字標籤
UILabel *nameView=[[UILabel alloc]init];
nameView.text=@“sd”;
nameView.tag=kLabelTag;
//設置center(居中)相對supperView
nameView.center=CGPointMake(viewWidth*.5, kRowHeight*.5);
//設置bounds(色澤寬高,不影響位置)
nameView.bounds=CGRectMake(0, 0, 200, 40);
//設置文字局中
nameView.textAlignment=NSTextAlignmentCenter;
//清除背景色
nameView.backgroundColor=[UIColor clearColor];
Button控件:
方法一:
UIButton *btn = [[UIButton alloc] init];
btn.frame = CGRectMake(0,0,100,100);
方法二:根據類型創建button,類型除UIButtonTypeCustom,其他無需指定寬高,只需指定center
UIButton *btn = [UIButton buttonWithType:UIButtonTypeContacteAdd];
btn.center = CGPointMake(100,100);
slider 控件
初始化:設置最大最小值
_slider.minimumValue=1;
_slider.maximumValue=_imageData.count;
取值:value爲浮點數s
_slider.value
switch控件:
參數:On 方法:isOn
imageView控件:
_imageView.image=[UIImage imageNamed:dict[@"icon”]
toolBar控件:
控件裏只能當Bar Button Item ,Item裏的identifier裏可選系統給的圖標樣式:其中Fixible Space可用於伸縮。
TextField控件:
// 設置鍵盤
self.myfield.inputView = picker;
// 設置鍵盤上面的工具條
self.myfield.inputAccessoryView = [UIButton buttonWithType:UIButtonTypeContactAdd];