您的位置:首页 > 其它

Xcode控件使用笔记一:label、Button、slider 、switch、imageView、toolBar、TextField

2015-05-13 14:31 549 查看
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];
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐