首页 > 其他 > 详细

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

时间:2016-07-13 23:25:49      阅读:355      评论:0      收藏:0      [点我收藏+]

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

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;

} 


本文出自 “ZhuoKing” 博客,请务必保留此出处http://9951038.blog.51cto.com/9941038/1826178

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

原文:http://9951038.blog.51cto.com/9941038/1826178

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!