您的位置:首页 > 产品设计 > UI/UE

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;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: