KKPaddingLabel 1.0.1

KKPaddingLabel 1.0.1

Cocoa维护。



  • cocoa

KKPaddingLabel

可以为 Label 添加内边距,支持 XIB 可视化修改,支持 autolayout/masonry 约束

xib 效果 动图

xib可视化编辑内边距

代码效果-灰色背景的 Label(见下图), Masonry 约束效果相同

KKPaddingLabel *paddingLabel = [[KKPaddingLabel alloc] initWithFrame:CGRectZero];
paddingLabel.text = @"KKPaddingLabel";
paddingLabel.backgroundColor = [UIColor lightGrayColor];
paddingLabel.padding = UIEdgeInsetsMake(10, 10, 10, 10);
paddingLabel.cornerRadius = 5.0f;
paddingLabel.translatesAutoresizingMaskIntoConstraints = NO;
[self.view addSubview:paddingLabel];

[self.view addConstraint:[NSLayoutConstraint constraintWithItem:paddingLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeTop multiplier:1.0 constant:200.0f]];
[self.view addConstraint:[NSLayoutConstraint constraintWithItem:paddingLabel attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeLeft multiplier:1.0 constant:100.0f]];

Image text