UItextfield在时间戳下添加额外的空格

时间:2014-05-07 10:11:16

标签: objective-c ios7 uitextfield

我有一个相对简单的评论框(UITextfield)用于照片应用,我在其中发现,当输入长评论(通常超过六个字)时,下方会出现大量空白注释框中的时间戳(" X分钟前")。帖子越长,框内出现的空格越多。其他一切正常,评论垂直对齐,时间戳正好在此之下。

self.backgroundColor = [UIColor clearColor];

    mainView = [[UIView alloc] initWithFrame:CGRectMake( 20.0f, 0.0f, 280.0f, 51.0f)];
    mainView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"BackgroundComments.png"]];
    [self addSubview:mainView];

    UIImageView *messageIcon = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"IconAddComment.png"]];
    messageIcon.frame = CGRectMake( 9.0f, 17.0f, 19.0f, 17.0f);
    [mainView addSubview:messageIcon];

    UIImageView *commentBox = [[UIImageView alloc] initWithImage:[[UIImage imageNamed:@"TextFieldComment.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(5.0f, 10.0f, 5.0f, 10.0f)]];
    commentBox.frame = CGRectMake(35.0f, 8.0f, 237.0f, 35.0f);
    [mainView addSubview:commentBox];

commentField = [[UITextField alloc] initWithFrame:CGRectMake( 40.0f, 10.0f, 227.0f, 31.0f)];
commentField.font = [UIFont systemFontOfSize:14.0f];
commentField.placeholder = @"Add a comment";
commentField.returnKeyType = UIReturnKeySend;
commentField.textColor = [UIColor colorWithRed:73.0f/255.0f green:55.0f/255.0f blue:35.0f/255.0f alpha:1.0f];
commentField.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
[commentField setValue:[UIColor colorWithRed:154.0f/255.0f green:146.0f/255.0f blue:138.0f/255.0f alpha:1.0f] forKeyPath:@"_placeholderLabel.textColor"]; 
[mainView addSubview:commentField];

非常感谢任何帮助!

0 个答案:

没有答案