UILabel-文字内边距
2016-06-12 14:06
288 查看
自定义UILabel类myLabel
myLabel.h文件中声明一个新的init方法:
- (instancetype)initWithFrame:(CGRect)frame insets:(UIEdgeInsets)insets;
myLabel.m文件中实现drawTextInRect方法:
@implementation myLabel
{
UIEdgeInsets _insets;
}
- (instancetype)initWithFrame:(CGRect)frame insets:(UIEdgeInsets)insets
{
if (self = [superinitWithFrame:frame]) {
_insets = insets;
}
returnself;
}
- (void)drawTextInRect:(CGRect)rect
{
return [superdrawTextInRect:UIEdgeInsetsInsetRect(rect,_insets)];
}
myLabel.h文件中声明一个新的init方法:
- (instancetype)initWithFrame:(CGRect)frame insets:(UIEdgeInsets)insets;
myLabel.m文件中实现drawTextInRect方法:
@implementation myLabel
{
UIEdgeInsets _insets;
}
- (instancetype)initWithFrame:(CGRect)frame insets:(UIEdgeInsets)insets
{
if (self = [superinitWithFrame:frame]) {
_insets = insets;
}
returnself;
}
- (void)drawTextInRect:(CGRect)rect
{
return [superdrawTextInRect:UIEdgeInsetsInsetRect(rect,_insets)];
}
相关文章推荐
- 全面解释java中StringBuilder、StringBuffer、String类之间的关系
- String、StringBuffer、StringBuilder的区别
- UITextField限制个数,没用代理
- 对AlertDialog.Builder进行封装
- (Builder)建造者模式的Java实现
- Redhat 官方Performance_Tuning_Guide
- UIlabel顶端对齐
- UI控件用法
- 这个函数的返回 值value的二进制位模式从左到右翻转后的值。
- C# StructLayout(LayoutKind.Sequential)]
- UITextField的基本使用
- Crank Storyboard Suite汽车仪表盘设计
- SecrueCRT 方向键不能使用
- easyui formatter实现超链接效果
- UIButton中setTitleEdgeInsets和setImageEdgeInsets的使用
- Android UI-开源框架ImageLoader的完美例子
- UIViewContentMode各类型效果
- 浅谈如何实现easyui的datebox格式化
- POJ-1458 Common Subsequence
- UI各种效果库