关于UITextFiled,UIlabel,UIBUtton相关设置,边框设置和字体设置


设置账号,密码字体的颜色

NSMutableDictionary *dict = [NSMutableDictionary dictionary];

dict[NSForegroundColorAttributeName] = [ICETools colorWithHexString:@"C1C0C2"];

NSAttributedString *attribute = [[NSAttributedString alloc] initWithString:self.accountTextFiled.placeholder attributes:dict];

[self.accountTextFiled setAttributedPlaceholder:attribute];

self.accountTextFiled.layer.cornerRadius = 2;

self.accountTextFiled.layer.borderColor = [[ICETools colorWithHexString:@"fb3c60"]CGColor];

self.accountTextFiled.layer.borderWidth = 1.2;

self.accountTextFiled.layer.masksToBounds = YES;

// UILabel

根据内容显示Label的一些设置 //给UILabel设置行间距和字间距 -(void)setLabelSpace:(UILabel)label withValue:(NSString)str withFont:(UIFont*)font {

NSMutableParagraphStyle *paraStyle = [[NSMutableParagraphStyle alloc] init];

paraStyle.lineBreakMode = NSLineBreakByCharWrapping;

paraStyle.alignment = NSTextAlignmentLeft;

paraStyle.lineSpacing = UILABEL_LINE_SPACE; //设置行间距

paraStyle.hyphenationFactor = 1.0;

paraStyle.firstLineHeadIndent = 0.0;

paraStyle.paragraphSpacingBefore = 0.0;

paraStyle.headIndent = 0;

paraStyle.tailIndent = 0;

//设置字间距 NSKernAttributeName:@1.5f

NSDictionary *dic = @{NSFontAttributeName:font, NSParagraphStyleAttributeName:paraStyle, NSKernAttributeName:@1.5f };

NSAttributedString *attributeStr = [[NSAttributedString alloc] initWithString:str attributes:dic];

label.attributedText = attributeStr;

}

//计算UILabel的高度(带有行间距的情况)

-(CGFloat)getSpaceLabelHeight:(NSString)str withFont:(UIFont)font withWidth:(CGFloat)width {

NSMutableParagraphStyle *paraStyle = [[NSMutableParagraphStyle alloc] init];

paraStyle.lineBreakMode = NSLineBreakByCharWrapping;

paraStyle.alignment = NSTextAlignmentLeft;

paraStyle.lineSpacing = UILABEL_LINE_SPACE;

paraStyle.hyphenationFactor = 1.0;

paraStyle.firstLineHeadIndent = 0.0;

paraStyle.paragraphSpacingBefore = 0.0;

paraStyle.headIndent = 0;

paraStyle.tailIndent = 0;

NSDictionary *dic = @{NSFontAttributeName:font, NSParagraphStyleAttributeName:paraStyle, NSKernAttributeName:@1.5f };

CGSize size = [str boundingRectWithSize:CGSizeMake(width, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOriginattributes:dic context:nil].size;

return size.height;

}

时间: 2024-08-25 09:36:43

关于UITextFiled,UIlabel,UIBUtton相关设置,边框设置和字体设置的相关文章

【C#】分享一个可灵活设置边框的Panel

注:此乃Winform控件,开发环境为.net 2.0 工作需要,我对自带Panel进行了一下呈现上的扩展,方便设置边框效果.先看效果: 说明: * 只有当原有属性BorderStyle为None时才能应用样式,此时可通过BorderMode设置[不显示.单色.三维]三种边框模式:这是因为BorderStyle为FixedSingle或Fixed3D时,自带边框似乎不属于Panel的一部分,不能控制或清除,我猜应该是底层API负责绘制的,所以唯有在None时才能自由发挥: * 无论单色或是三维模

使用CSS设置边框和beijing

一.设置边框 1.边框样式 属性 说明 border-width 设置边框的宽度 boder-style 设置边框的样式 border-color 设置边框的颜色 a.border-width属性 自定义边框的宽度时,不能定义为百分比. b.border-style属性 以上属性可以设置一个.二个.三个.四个属性值,当设置一个值得时候四条边框都应用该属性值,当设置两个的时候时候上下使用第一个属性值,左右使用第二个属性值,当设置三个值的时候,第一个值应用在上边框,第二个应用到左右边框,第三个属性值

UILabel && UIButton

一.效果展示 1. 启动界面只有一个按钮 2. 点击按钮,显示文本信息 二. 分析 1. 两个控件UILabel && UIButton 2. 点击按钮触动方法设置文本信息 三. 实现 1. 不加载Main.storyboard 2. APPDelegate.m 1 // 2 // AppDelegate.m 3 // 4.1-标签和按钮 4 // 5 // Created by LinKun on 16/8/31. 6 // Copyright © 2016年 Lkun. All rig

CFileDialog(文件夹对话框类)和CFontDialog(字体设置对话框类)的使用学习

CFileDialog(文件夹对话框类) 主要用于文件的保存,另存,打开,关闭等功能 功能“另存为”的实现: 1 void CTXTDlg::OnFileSaveas() 2 { 3 LPCTSTR szFilter = "文本文件(*.txt)|*.txt|所有文件(*.*)|*.*||"; //过滤器设置,注意格式 4 CFileDialog fd(FALSE,"txt",NULL,OFN_OVERWRITEPROMPT|OFN_PATHMUSTEXIST| /

UILabel的相关属性设置

在iOS编程中UILabel是一个常用的控件,下面分享一下UILabel的相关属性设置的方法. 很多学习iOS6编程都是从storyboard开始,用到UILabel时是将控件拖到storyboard中生成实现,如果想要在-(void)viewDidLoad中用代码如[_label initWithFrame:CGRectMake(X,Y,WIDTH,HEIGHT)]方法改变拖拽到storyboard的label的大小是行不通的,因为程序加载时先执行了-(void)viewDidLoad的代码,

ios中设置UIButton圆角,添加边框

//例如: UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; button.frame = CGRectMake(50,50,100,40); button.backgroundColor = [UIColor blueColor]; //关键语句 button.layer.cornerRadius = 2.0;//2.0是圆角的弧度,根据需求自己更改 button.layer.borderColor = [UICo

设置UIButton的文字显示位置、字体的大小、字体的颜色、加粗

btn.frame = CGRectMake(x, y, width, height); [btn setTitle: @"search" forState: UIControlStateNormal]; //设置按钮上的自体的大小 //[btn setFont: [UIFont systemFontSize: 14.0]];    //这种可以用来设置字体的大小,但是可能会在将来的SDK版本中去除改方法 //应该使用 btn.titleLabel.font = [UIFont sys

iOS开发-- 设置UIButton的文字显示位置、字体的大小、字体的颜色

btn.frame = CGRectMake(x, y, width, height); [btn setTitle: @"search" forState: UIControlStateNormal]; //设置按钮上的自体的大小 //[btn setFont: [UIFont systemFontSize: 14.0]];    //这种可以用来设置字体的大小,但是可能会在将来的SDK版本中去除改方法 //应该使用 btn.titleLabel.font = [UIFont sys

Android表格布局之设置边框

Android表格布局本身没有边框,不过可以通过背景色的设置可以实现表格边框的显示. 首先可以设置TableRow的背景色,然后设置内容的背景色.根据它们的颜色差就出现了边框.只要微调Content与TableRow的margin和pading属性就可以了! 调的过程真是烦人!下次不做这种工作了~呜呜!难受! 贴上布局代码: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xml