我的UI Inspector中没有任何内容显示在屏幕底部。
我真的很难过可能导致这个问题的原因。无论它是什么阻止数字/符号切换器,键盘语言(或表情符号)选择器和语音到文本按钮。同一行的空格键和返回键继续正常运行。
受影响的UITextField是子类,键盘在包含它们的其他5个视图中按预期工作,但这是他们的代码:
JCTextField.h
#import <UIKit/UIKit.h>
IB_DESIGNABLE
@interface JCTextField : UITextField
@property (nonatomic, retain) IBInspectable UIColor *underlineColor;
@property (nonatomic) IBInspectable CGFloat underlineWidth;
@property (nonatomic, retain) IBInspectable UIImage *sideImage;
@property (nonatomic) IBInspectable CGFloat internalOffset;
@property (nonatomic) IBInspectable CGFloat borderOffset;
@end
JCTextField.m
#import "JCTextField.h"
@implementation JCTextField
- (id)initWithCoder:(NSCoder *)aDecoder {
self = [super initWithCoder:aDecoder];
if(self != nil) {
self.underlineColor = [UIColor blackColor];
self.underlineWidth = 1;
self.internalOffset = 0;
self.borderOffset = 0;
}
return self;
}
- (void)layoutSubviews {
[super layoutSubviews];
CALayer *border = [CALayer layer];
border.borderColor = _underlineColor.CGColor;
border.frame = CGRectMake(_borderOffset, self.frame.size.height - _underlineWidth, self.frame.size.width - (_borderOffset * 2), self.frame.size.height);
border.borderWidth = _underlineWidth;
[self.layer addSublayer:border];
self.layer.masksToBounds = YES;
[self setValue:[UIColor lightTextColor] forKeyPath:@"_placeholderLabel.textColor"];
[self setTextColor:[UIColor whiteColor]];
[self setFont:[UIFont fontWithName:@"Montserrat-Regular" size:16.0]];
if (self.sideImage) {
UIImageView *sideImageView = [[UIImageView alloc] initWithFrame:CGRectMake(self.frame.size.width - 30, 0, 30, 30)];
sideImageView.contentMode = UIViewContentModeCenter;
sideImageView.image = self.sideImage;
[self addSubview:sideImageView];
}
[self setTintColor:[UIColor whiteColor]];
[self setValue:[UIColor lightGrayColor] forKeyPath:@"_placeholderLabel.textColor"];
}
- (CGRect)textRectForBounds:(CGRect)bounds {
if (self.sideImage) {
UIEdgeInsets insets = UIEdgeInsetsMake(0, _internalOffset, 0, 18);
return [super textRectForBounds:UIEdgeInsetsInsetRect(bounds, insets)];
}
UIEdgeInsets insets = UIEdgeInsetsMake(0, _internalOffset, 0, 0);
return [super textRectForBounds:UIEdgeInsetsInsetRect(bounds, insets)];
}
- (CGRect)editingRectForBounds:(CGRect)bounds {
if (self.sideImage) {
UIEdgeInsets insets = UIEdgeInsetsMake(0, _internalOffset, 0, 18);
return [super textRectForBounds:UIEdgeInsetsInsetRect(bounds, insets)];
}
UIEdgeInsets insets = UIEdgeInsetsMake(0, _internalOffset, 0, 0);
return [super textRectForBounds:UIEdgeInsetsInsetRect(bounds, insets)];
}
@end