Your Site Title

iOS UIView

Label设置多样式

NSMutableAttributedString *taskSumApplyLabAS = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"共%@次", data[@"ljsqrw"]]];
[taskSumApplyLabAS setAttributes:@{NSForegroundColorAttributeName:[[UIColor alloc] initWithRed:255/255.0 green:169/255.0 blue:49/255.0 alpha:1], NSFontAttributeName:[UIFont systemFontOfSize:13]} range:NSMakeRange(1, taskSumApplyLabAS.length - 2)];
_taskSumApplyLab.attributedText = taskSumApplyLabAS;

设置透明背景

sefl.view.backgroudColor = [UIColor blackColor];
self.view.alpha = 0.1;

self.view.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.02];

获取宽高

使用Autolayout时, viewDidLoad中自动布局还没有执行, 所以不能获取实际宽高 可以在viewDidLoad, viewDidLayoutSubviews, layoutSubviews中获取

或者获取屏幕宽高自己算

[[[UIApplication sharedApplication] keyWindow] bounds] [[[[UIApplication sharedApplication] delegate] window] bounds] [[UIScreen mainScreen] bounds]

修改约束

修改约束不能在viewDidLoad中, viewDidLoad中设置后xib会覆盖回来. 需要延迟修改

自定义View

xib Size 需要设置成Freeform

Reference