Using a custom font in a UITextField causes it to shift slightly when accessed — is there a fix?

前端 未结 10 2006
后悔当初
后悔当初 2020-12-13 14:32

I have a custom font in a UITextField, and I\'ve noticed that when it\'s accessed (when the keyboard appears), the text shifts down by a very small amount -- maybe

10条回答
  •  醉话见心
    2020-12-13 14:50

    I had this issue with a custom font and solved it by shifting the label in the other direction when the keyboard events would fire. I moved the center of the label in the button by overriding the drawRect: method

    - (void)drawRect:(CGRect)rect
    {
        self.titleLabel.center = CGPointMake(self.titleLabel.center.x, self.titleLabel.center.y+3);
    }
    

提交回复
热议问题