如图这样的,storyboard里面找textfield的属性面板没有找到解决方法~求指教。
你可能要用代码解决:
UITextField *textField = [[UITextField alloc] init];
[textField setLeftViewMode:UITextFieldViewModeAlways];
[textField setLeftView:<#your-icon-image-view#>];
自带属性leftView和rightView
- (void)configureUserText:(rewriteFiled *)text {
text.clearButtonMode = UITextFieldViewModeWhileEditing;
text.adjustsFontSizeToFitWidth = YES;
text.returnKeyType = UIReturnKeyDone;
self.userView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 70, 30)];
UIImageView *userMageView = [[UIImageView alloc] initWithFrame:CGRectMake(5, 4.5, 22, 22)];
userMageView.image = [UIImage imageNamed:@"user"];
UILabel *userName = [[UILabel alloc] initWithFrame:CGRectMake(30, 4, 40, 22)];
userName.text = @"账号:";
userName.font = [UIFont systemFontOfSize:15];
[self.userView addSubview:userMageView];
[self.userView addSubview:userName];
text.leftView = self.userView;
text.leftViewMode = UITextFieldViewModeAlways;
text.delegate = self;
}
2 回答1k 阅读
1 回答1.1k 阅读✓ 已解决
1 回答2.7k 阅读
1 回答1.5k 阅读
1 回答1.4k 阅读
1.7k 阅读
1 回答1.1k 阅读
我要怒答此题! (刚刚学的新知识终于有机会装逼了)
在
Xcode 6
里面新引入俩个关键字来更友好的使用 Storyboard,分别是@IBInspectable: 被这个关键字所修饰的属性,可以在
IB
的属性页里面进行设置@IBDesignable: 可以让你的
UIView
及其子类, 代码里面的操作的视图的结果显示到Storyboard
对应的View
上意思就是说我们可以使用这俩个关键字来达到题主所需要的效果, 如图:
该
HJTextFeild
代码如下:参考链接: NSHipster IBInspectable / IBDesignable