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 的位置


基础教程推荐
- AdMob 广告未在模拟器中显示 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01