gpt4 book ai didi

iphone - UITextField 垂直对齐

转载 作者:行者123 更新时间:2023-12-03 18:12:23 24 4
gpt4 key购买 nike

有没有一种方法可以将 UITextField 中的文本垂直对齐在 UIControlContentVerticalAlignmentCenterUIControlContentVerticalAlignmentBottom 之间,或者我必须采用一种方法其中?

最佳答案

您应该子类化 UITextField,并重写以下方法:

- (CGRect) textRectForBounds: (CGRect) bounds
{
CGRect origValue = [super textRectForBounds: bounds];

/* Just a sample offset */
return CGRectOffset(origValue, 0.0f, 4.0f);
}

- (CGRect) editingRectForBounds: (CGRect) bounds
{
CGRect origValue = [super textRectForBounds: bounds];

/* Just a sample offset */
return CGRectOffset(origValue, 0.0f, 4.0f);
}

关于iphone - UITextField 垂直对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3261404/

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