1、修改textFieldplaceholder字体颜色和大小
textField.placeholder = @"请输入用户名";
[textField setValue:[UIColor redColor] forKeyPath:@"_placeholderLabel.textColor"];
[textField setValue:[UIFont boldSystemFontOfSize:16] forKeyPath:@"_placeholderLabel.font"];
2、设置UILable 的行间距 和 计算带行间距的高度
/*
UILabel* 展示的控件
(NSString*)str 内容
withFont:(float)font 字体大小
WithSpace:(float)space 行间距
*/
//给UILabel设置行间距和字间距
-(void)setLabelSpace:(UILabel*)label withValue:(NSString*)str withFont:(float)font WithSpace:(float)space{
NSMutableParagraphStyle *paraStyle = [[NSMutableParagraphStyle alloc] init];
paraStyle.lineBreakMode = NSLineBreakByCharWrapping;
paraStyle.alignment = NSTextAlignmentLeft;
paraStyle.lineSpacing = space; //设置行间距
paraStyle.hyphenationFactor = 1.0;
paraStyle.firstLineHeadIndent = 0.0;
paraStyle.paragraphSpacingBefore = 0.0;
paraStyle.headIndent = 0;
paraStyle.tailIndent = 0;
//设置字间距 NSKernAttributeName:@1.5f
UIFont *tfont = [UIFont systemFontOfSize:font];
NSDictionary *dic = @{NSFontAttributeName:tfont, NSParagraphStyleAttributeName:paraStyle, NSKernAttributeName:@1.5f
};
NSAttributedString *attributeStr = [[NSAttributedString alloc] initWithString:str attributes:dic];
label.attributedText = attributeStr;
}
/*
计算UILabel的高度(带有行间距的情况)
(NSString*)str 内容
withFont:(float)font 字体大小
WithSpace:(float)space 行间距
(CGFloat)width UILable的宽度
*/
//计算UILabel的高度(带有行间距的情况)
-(CGFloat)getSpaceLabelHeight:(NSString*)str withFont:(float)font withWidth:(CGFloat)width WithSpace:(float)space{
NSMutableParagraphStyle *paraStyle = [[NSMutableParagraphStyle alloc] init];
paraStyle.lineBreakMode = NSLineBreakByCharWrapping;
paraStyle.alignment = NSTextAlignmentLeft;
paraStyle.lineSpacing = space;
paraStyle.hyphenationFactor = 1.0;
paraStyle.firstLineHeadIndent = 0.0;
paraStyle.paragraphSpacingBefore = 0.0;
paraStyle.headIndent = 0;
paraStyle.tailIndent = 0;
UIFont *tfont = [UIFont systemFontOfSize:font];
NSDictionary *dic = @{NSFontAttributeName:tfont, NSParagraphStyleAttributeName:paraStyle, NSKernAttributeName:@1.5f
};
CGSize size = [str boundingRectWithSize:CGSizeMake(width, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil].size;
return size.height;
}
3、图片阴影
UIImageView *userImageView = [[UIImageView alloc] init];
userImageView.backgroundColor = [UIColor whiteColor];
userImageView.layer.cornerRadius = 7;
// userImageView.layer.masksToBounds = YES;
userImageView.layer.shadowColor = _Main_BlueColor.CGColor;
userImageView.layer.shadowOpacity = 0.1f;
userImageView.layer.shadowRadius = 5;
userImageView.layer.shadowOffset = CGSizeMake(4,4);
网友评论