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

发布时间:2020-09-03 00:00:48 作者:卓行天下
来源:网络 阅读:626

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

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;

} 


推荐阅读:
  1. iOS UILabel设置行高代码解析
  2. iOS UILabel 设置行高

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

密码 账号 te

上一篇:图示化编程最好用的中文开发平台几天就会开发软件

下一篇:C#中Hash table的一些操作方法讲解

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》