IOS UI view button 自定义颜色………
2013-09-22 14:23
435 查看
UIView *
view=[[UIView
alloc]initWithFrame:CGRectMake_View];
view.backgroundColor=[UIColor
colorWithPatternImage:[UIImage
imageNamed:@"123.jpeg"]];
[self.window
addSubview:view];
//button
//UIButtonTypeDetailDisclosure 向右
UIButtonTypeInfoDark没反应
UIButtonTypeRoundedRect圆角
UIButton * button=[UIButton
buttonWithType:UIButtonTypeCustom];
[button
setImage:[UIImage
imageNamed:@"14.png"]forState:UIControlStateNormal];//点14.png
显示7.png
[button
setImage:[UIImage
imageNamed:@"7.png"]forState:UIControlStateHighlighted];
[button
setFrame:CGRectMake_button];
[view
addSubview:button];
//button1
UIButton * button1=[UIButton
buttonWithType:UIButtonTypeCustom];
button1.frame=CGRectMake_button1;
//button1.backgroundColor=[UIColor redColor];
button1.backgroundColor=[UIColor
colorWithRed:(12/255)
green:(22/255)
blue:(32/255)alpha:1.0];
//自定义颜色
[view
addSubview:button1];
//textField
UITextField
* field=[[UITextField
alloc]initWithFrame:CGRectMake_field];
field.backgroundColor=[UIColor
whiteColor];
field.textAlignment=UITextAlignmentRight;//文字在右边
field.font=[UIFont
systemFontOfSize:33];//文本框中的文字大小
//让控件失去用户交互 不可编辑
field.userInteractionEnabled =
NO;
field.borderStyle
=UITextBorderStyleBezel ;
//文本框类型
===========================================================
UIView
* view=[[UIView alloc]initWithFrame:CGRectMake_View];
view.backgroundColor=[UIColor colorWithPatternImage:[UIImage
imageNamed:@"123.jpeg"]];
[self.window addSubview:view];
//button
//UIButtonTypeDetailDisclosure
向右
UIButtonTypeInfoDark没反应
UIButtonTypeRoundedRect圆角
UIButton
* button=[UIButton
buttonWithType:UIButtonTypeCustom];
[button setImage:[UIImage
imageNamed:@"14.png"]forState:UIControlStateNormal];//点14.png 显示7.png
[button setImage:[UIImage
imageNamed:@"7.png"]forState:UIControlStateHighlighted];
[button setFrame:CGRectMake_button];
[view
addSubview:button];
//button1
UIButton
* button1=[UIButton
buttonWithType:UIButtonTypeCustom];
button1.frame=CGRectMake_button1;
//button1.backgroundColor=[UIColor
redColor];
button1.backgroundColor=[UIColor colorWithRed:(12/255) green:(22/255) blue:(32/255)alpha:1.0]; //自定义颜色
[view
addSubview:button1];
//textField
UITextField *
field=[[UITextField alloc]initWithFrame:CGRectMake_field];
field.backgroundColor=[UIColor whiteColor];
field.textAlignment=UITextAlignmentRight;//文字在右边
field.font=[UIFont
systemFontOfSize:33];//文本框中的文字大小
//让控件失去用户交互
不可编辑
field.userInteractionEnabled = NO;
field.borderStyle
=UITextBorderStyleBezel ; //文本框类型
[view
addSubview:field];
===============================================================
Label
字体
UILabel
*label2=[[UILabel
alloc]initWithFrame:CGRectMake(33, 33, 99, 66)];
[label2 setNumberOfLines:1];
label2.textColor=[UIColor redColor];
label2.font=[UIFont
fontWithName:@"宋体"
size:50.0f];
label2.text=@"字符串大小";
======================================
NSString
* s=@"字符串字符串大小字符串大小字符串大小字符串大小字符串大小字符串大小字符串大小字符串大小字符串大小字符串大小大小";
UIFont * font=[UIFont
fontWithName:@"黑体"
size:44.0f];
CGSize size=CGSizeMake(66, 70);
UILabel *label2=[[UILabel alloc]initWithFrame:CGRectZero];
[label2 setNumberOfLines:0];
CGSize labelsize=[s
sizeWithFont:font
constrainedToSize:size
lineBreakMode:UILineBreakModeCharacterWrap]; //折行
//label2.frame=CGRectMake(33, 33, 99,
33);
label2.frame=CGRectMake(33, 33, 55, 55);
label2.textColor=[UIColor blackColor];
label2.font=font;
label2.text=s;
view=[[UIView
alloc]initWithFrame:CGRectMake_View];
view.backgroundColor=[UIColor
colorWithPatternImage:[UIImage
imageNamed:@"123.jpeg"]];
[self.window
addSubview:view];
//button
//UIButtonTypeDetailDisclosure 向右
UIButtonTypeInfoDark没反应
UIButtonTypeRoundedRect圆角
UIButton * button=[UIButton
buttonWithType:UIButtonTypeCustom];
[button
setImage:[UIImage
imageNamed:@"14.png"]forState:UIControlStateNormal];//点14.png
显示7.png
[button
setImage:[UIImage
imageNamed:@"7.png"]forState:UIControlStateHighlighted];
[button
setFrame:CGRectMake_button];
[view
addSubview:button];
//button1
UIButton * button1=[UIButton
buttonWithType:UIButtonTypeCustom];
button1.frame=CGRectMake_button1;
//button1.backgroundColor=[UIColor redColor];
button1.backgroundColor=[UIColor
colorWithRed:(12/255)
green:(22/255)
blue:(32/255)alpha:1.0];
//自定义颜色
[view
addSubview:button1];
//textField
UITextField
* field=[[UITextField
alloc]initWithFrame:CGRectMake_field];
field.backgroundColor=[UIColor
whiteColor];
field.textAlignment=UITextAlignmentRight;//文字在右边
field.font=[UIFont
systemFontOfSize:33];//文本框中的文字大小
//让控件失去用户交互 不可编辑
field.userInteractionEnabled =
NO;
field.borderStyle
=UITextBorderStyleBezel ;
//文本框类型
===========================================================
UIView
* view=[[UIView alloc]initWithFrame:CGRectMake_View];
view.backgroundColor=[UIColor colorWithPatternImage:[UIImage
imageNamed:@"123.jpeg"]];
[self.window addSubview:view];
//button
//UIButtonTypeDetailDisclosure
向右
UIButtonTypeInfoDark没反应
UIButtonTypeRoundedRect圆角
UIButton
* button=[UIButton
buttonWithType:UIButtonTypeCustom];
[button setImage:[UIImage
imageNamed:@"14.png"]forState:UIControlStateNormal];//点14.png 显示7.png
[button setImage:[UIImage
imageNamed:@"7.png"]forState:UIControlStateHighlighted];
[button setFrame:CGRectMake_button];
[view
addSubview:button];
//button1
UIButton
* button1=[UIButton
buttonWithType:UIButtonTypeCustom];
button1.frame=CGRectMake_button1;
//button1.backgroundColor=[UIColor
redColor];
button1.backgroundColor=[UIColor colorWithRed:(12/255) green:(22/255) blue:(32/255)alpha:1.0]; //自定义颜色
[view
addSubview:button1];
//textField
UITextField *
field=[[UITextField alloc]initWithFrame:CGRectMake_field];
field.backgroundColor=[UIColor whiteColor];
field.textAlignment=UITextAlignmentRight;//文字在右边
field.font=[UIFont
systemFontOfSize:33];//文本框中的文字大小
//让控件失去用户交互
不可编辑
field.userInteractionEnabled = NO;
field.borderStyle
=UITextBorderStyleBezel ; //文本框类型
[view
addSubview:field];
===============================================================
Label
字体
UILabel
*label2=[[UILabel
alloc]initWithFrame:CGRectMake(33, 33, 99, 66)];
[label2 setNumberOfLines:1];
label2.textColor=[UIColor redColor];
label2.font=[UIFont
fontWithName:@"宋体"
size:50.0f];
label2.text=@"字符串大小";
======================================
NSString
* s=@"字符串字符串大小字符串大小字符串大小字符串大小字符串大小字符串大小字符串大小字符串大小字符串大小字符串大小大小";
UIFont * font=[UIFont
fontWithName:@"黑体"
size:44.0f];
CGSize size=CGSizeMake(66, 70);
UILabel *label2=[[UILabel alloc]initWithFrame:CGRectZero];
[label2 setNumberOfLines:0];
CGSize labelsize=[s
sizeWithFont:font
constrainedToSize:size
lineBreakMode:UILineBreakModeCharacterWrap]; //折行
//label2.frame=CGRectMake(33, 33, 99,
33);
label2.frame=CGRectMake(33, 33, 55, 55);
label2.textColor=[UIColor blackColor];
label2.font=font;
label2.text=s;
相关文章推荐
- ios开发 button或UIimageview加载图片显示颜色不显示图片
- IOS 纯代码添加 Button Image Label 添加到自定义View中
- iOS开发——UI基础-懒加载,plist文件,字典转模型,自定义view
- IOS init、loadView、viewDidLoad…
- iOS 的TextView的常规用法
- iOS——button&&imageview的学习笔记
- ios中修改自定义PickerView的字体颜色
- iOS 添加自定义字体方法详解
- iOS学习之UITableView中Cell…
- ios多个view 同时放大 同时缩小
- ios 自定义地图吹出框(CalloutView)-->(百度地图,高德地图,google地图)
- IOS loadView,viewDidLoad,viewDid…
- iOS TextView自动滚动到最后一行
- 安卓UI 自定义View SwitchButton
- iOS UISplitViewController 开发(iOS8)
- iOS学习之Table View的…
- Android TextView字体颜色跟…
- IOS 如何让UITableVIew的行纪录 不…
- iOS开发 - 第02篇 - UI进阶 - 06 - PickerView & DatePicker
- iOS UIAlertController跟AlertView用法一样 && otherButtonTitles:(nullable NSString *)otherButtonTitles, ... 写法