【发布时间】:2016-01-06 06:58:25
【问题描述】:
我继承了UITextField:
#import <UIKit/UIKit.h>
IB_DESIGNABLE
@interface TWAdjustmentsTextField : UITextField
@property (nonatomic) IBInspectable NSInteger topInset;
@property (nonatomic) IBInspectable NSInteger leftInset;
@end
#import "TWAdjustmentsTextField.h"
@implementation TWAdjustmentsTextField
- (CGRect)textRectForBounds:(CGRect)bounds {
return CGRectInset(bounds, self.leftInset, self.topInset);
}
- (CGRect)editingRectForBounds:(CGRect)bounds {
return CGRectInset(bounds, self.leftInset, self.topInset);
}
@end
leftInset 属性似乎工作正常,但topInset 属性似乎对 UITextFields 没有影响。还有其他方法可以调整 UITextField 的顶部插图吗?
【问题讨论】:
-
我想知道你是否应该调整字体大小。
-
@Lumialxk 字体大小对我的问题没有帮助。我的问题是我需要偏移 UITextField 内的文本,以便它稍微对齐 UITextField 的底部边缘
标签: ios objective-c iphone uitextfield