gpt4 book ai didi

ios - 如何为 UITextField 制作边框填充?

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:17:40 25 4
gpt4 key购买 nike

当然,我在这里看到很多 Core Graphics 问题,所以如果这是一个骗局,请将我转到现有答案。

在 ScrollView 中,我有一些标签和文本字段。文本字段有边框。

我似乎想不通的是如何在边框和文本之间添加填充。

您可以在这张图片中看到发生了什么:

enter image description here

这是执行此操作的代码片段:

roughDate = [[UITextField alloc] init] ;
CGRect tempFrame = CGRectMake(125, 90, 300, 40);
UIEdgeInsets insets = UIEdgeInsetsMake(4, 4, 4, 4);
CGRect roughDateFrame = UIEdgeInsetsInsetRect(tempFrame, insets);
NSLog(@"%@", NSStringFromCGRect(roughDateFrame));
[[roughDate layer] setBorderColor:[[UIColor grayColor] CGColor]];
[[roughDate layer] setBorderWidth:1.0];
[[roughDate layer] setCornerRadius:5];
roughDate.frame = roughDateFrame;
[subview addSubview:roughDate];

最佳答案

使用这个:

_textField.leftView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 12, 20)];
_textField.leftViewMode = UITextFieldViewModeAlways;
_textField.background = [[UIImage imageNamed:@"image"] stretchableImageWithLeftCapWidth:7 topCapHeight:17];

关于ios - 如何为 UITextField 制作边框填充?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18225791/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com