Position of rightView UITextField(rightView UITextField 的位置)
问题描述
有没有办法在 UITextField 上调整 rightView 的位置?我尝试在视图上设置框架(设置为 rightView),但没有任何改变.
Is there a way to adjust the position of a rightView on UITextField? I tried setting the frame on the view (set as rightView) but it didn't change anything.
我想避免制作两个视图,一个作为 rightView,一个作为 rightView 的子视图,如果可能的话,我会在其中更改子视图的位置.
I'd like to avoid making two views, one as the rightView and one as the rightView's subview where I change the subview's position, if possible.
推荐答案
右叠加视图放置在接收方的rightViewRectForBounds
:方法返回的矩形中.
The right overlay view is placed in the rectangle returned by the rightViewRectForBounds
: method of the receiver.
所以我建议你继承 UITextField
并覆盖这个方法,像这样:
So I suggest you subclass UITextField
and override this method, something like this:
@interface CustomTextField: UITextField
@end
@implementation CustomTextField
// override rightViewRectForBounds method:
- (CGRect)rightViewRectForBounds:(CGRect)bounds{
CGRect rightBounds = CGRectMake(bounds.origin.x + 10, 0, 30, 44);
return rightBounds ;
}
这篇关于rightView UITextField 的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:rightView UITextField 的位置


- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01
- 想使用ViewPager,无法识别android.support.*? 2022-01-01
- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01
- Android - 我如何找出用户有多少未读电子邮件? 2022-01-01
- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01
- 用 Swift 实现 UITextFieldDelegate 2022-01-01
- Android viewpager检测滑动超出范围 2022-01-01
- android 4中的android RadioButton问题 2022-01-01
- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01
- Android - 拆分 Drawable 2022-01-01