UITextField placeholder string is always Top aligned in ios7

后端 未结 6 2635
滥情空心
滥情空心 2021-02-20 00:44

I have subclass the UITextField class and did the below code

- (void)drawPlaceholderInRect:(CGRect)rect
{

    [self.placeHolderTextColor setFill];
    [self.pl         


        
6条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-20 01:09

    I have fixed this problem by subclassing UITextFieldClass and override drawPlaceholderInRect function.

     - (void)drawPlaceholderInRect:(CGRect)rect
    {
    
        if(IS_IOS7)
        {
            [[self placeholder] drawInRect:CGRectMake(rect.origin.x, rect.origin.y+10, rect.size.width, rect.size.height) withFont:self.font];
        }
        else {
    
            [[self placeholder] drawInRect:rect withFont:self.font];
        }
    }
    

提交回复
热议问题