阅读背景:

iOS中UITextView的默认输入居中,而非顶部的解决办法

来源:互联网 
    UITextView *textView = [[UITextView alloc] init];
    [self.view addSubview:textView];
    
    textView.frame = CGRectMake(0, 0, 100, 100); // 自己随便定义
    textView.font = [UIFont systemFontOfSize:17.0]; // 设置字体大小
    CGFloat fontCapHeight = textView.font.capHeight; // 文字大小所占的高度
    CGFloat topMargin = 10; // 跟顶部的间距
    textView.contentInset = UIEdgeInsetsMake(-textView.frame.size.height*0.5 + fontCapHeight + topMargin, 0, 0, 0);    UITextView *textView = [[UITextView alloc] 



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: