IOS UI view button 自定义颜色………

 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;



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值