【问题标题】:How to create a UITextField like find Iphone如何创建一个 UITextField 像 find Iphone
【发布时间】:2014-01-05 21:13:35
【问题描述】:

我想创建一个UITextField,比如查找 iPhone。

我对@9​​87654324@ 使用了以下代码:

UIBezierPath *maskPathBotton = [UIBezierPath bezierPathWithRoundedRect:txtSenha.bounds byRoundingCorners:UIRectCornerBottomLeft|UIRectCornerBottomRight cornerRadii:CGSizeMake(8.0, 8.0)];

txtSenha.borderStyle=UITextBorderStyleNone;

CAShapeLayer *maskLayerBotton = [CAShapeLayer layer];
maskLayerBotton.frame = txtSenha.bounds;
maskLayerBotton.path = maskPathBotton.CGPath;
maskLayerBotton.fillColor=[UIColor whiteColor].CGColor;
maskLayerBotton.strokeColor=[UIColor lightGrayColor].CGColor;
maskLayerBotton.lineWidth=1.5;

[txtSenha.layer addSublayer:maskLayerBotton];

但结果并不是那么好。

在角落的笔触与其他线条略有不同。如何创建相同的UITextField。对不起,我的英语和没有图片,我没有足够的声誉来上传图片。

编辑: 来自 Find Iphone 的 UITextField

而这个,是我能做到的。

【问题讨论】:

  • 完全不清楚您要做什么。您是否正在尝试创建一个具有 UITextView 外观的自定义视图,并带有框?
  • 这就像两个 UITextField 在一起。我用图片链接更新帖子。
  • 如果我没记错的话,它是一个在侧单元格中带有 uitextfield 的 uitableview。
  • 在clearbackground颜色情况下使用图像 拍摄背景图像并在其上放置透明文本

标签: ios iphone objective-c uitextfield


【解决方案1】:

如果你想要圆角试试这个

textField.layer.cornerRadius = 10;

请务必包含 #import <QuartzCore/QuartzCore.h> 以访问此内容。

从您的代码中删除这一行

textField.borderStyle = UITextBorderStyleRoundedRect;

而不是

[textField setBackgroundColor:[UIColor clearColor]];
[textField.layer setBorderColor:[UIColor grayColor].CGColor];
[textField.layer setBorderWidth:1.0];

【讨论】:

  • 我无法使用“textField.layer.cornerRadius = 10;”因为我只想在第一个 textField 的左上角和右上角制作圆角,而在第二个 textField 的左下角和右下角制作圆角。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-02-19
  • 2010-11-23
  • 1970-01-01
  • 1970-01-01
  • 2012-01-09
相关资源
最近更新 更多