ios uitextfield就像笔记一样

ghi*_*boz 2 iphone background uitextfield ios

我希望我的uitextfield看起来像iPhone的笔记,黄色的线条......最好的方法是什么?提前致谢!

f0r*_*0rz 5

你的意思是UItextview对吗?...它不是UITextField.但是,请清除UITextView上的背景.

self.textView.backgroundColor =  [UIColor clearColor];
Run Code Online (Sandbox Code Playgroud)

然后创建将您作为子视图放入textview的ImageView.

backgroundimage = [[UIImageView alloc] initWithFrame: CGRectMake(0, -14,textView.frame.size.width, textView.fram.size.height)];
Run Code Online (Sandbox Code Playgroud)

将图案图像设置为backgroundColor.这将是你的线.只需创建两行或两行.然后它应该重演.

backgroundimage.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"lines.png"];
Run Code Online (Sandbox Code Playgroud)

然后将您的子视图添加到textview.

[self.textView addSubview:backgroundimage];
Run Code Online (Sandbox Code Playgroud)

祝好运!

  • 而不是创建一个backgroundView,只需将`UITextView`的背景颜色设置为`[UIColor colorWithPatternImage:[UIImage imageNamed:@"lines.png"]; (2认同)