关于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:fontNSParagraphStyleAttributeName:paraStyleNSKernAttributeName:@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:fontNSParagraphStyleAttributeName:paraStyleNSKernAttributeName:@1.5f };

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

return size.height;

} 










本文转自 卓行天下  51CTO博客,原文链接:http://blog.51cto.com/9951038/1826178,如需转载请自行联系原作者
目录
相关文章
UITextView设置边框
UITextView设置边框
46 0
|
iOS开发
修改UISearchBar背景颜色
修改UISearchBar背景颜色
138 0
UILabel 调整行间距
UILabel 调整行间距
59 0
同一个UILabel不同的字体颜色
同一个UILabel不同的字体颜色
49 0
UIImageView加上圆角
UIImageView加上圆角
40 0
UIView添加圆角边框
UIView添加圆角边框
61 0
三种方法设置UITextField的占位文字颜色
三种方法设置UITextField的占位文字颜色
208 0
|
Swift
Swift之设置UItextField的占位文字颜色颜色
Swift之设置UItextField的占位文字颜色颜色
219 0
Swift之设置UItextField的占位文字颜色颜色
|
UED 缓存 异构计算
UIImageView添加圆角的几种方法
喜欢我的可以关注收藏我的个人博客:RobberJJ 创建一个UIImageView对象: UIImageView * poImgView = [[UIImageView alloc] init]; 第一种方法 poImgView.
943 0