我的文本视图在 iOS 6 中的格式良好,但在 iOS 7 中不再正常工作。我知道 Text Kit 大部分底层技术已经改变了。这变得非常令人困惑,希望有人可以通过帮我解决这个简单的问题来帮助我搞清楚一些事情。
我的静态 UITextView 最初为其 textColor
和 textAlignment
属性分配了值。然后我创建了一个 NSMutableAttributedString
,为它分配了属性,然后将其赋值给 textView 的 attributedText
属性。在 iOS 7 中,对齐和颜色不再生效。
我该如何解决这个问题?如果这些属性不起作用,那么它们还存在的意义是什么?下面是 textView 的创建:
UITextView *titleView = [[UITextView alloc]initWithFrame:CGRectMake(0, 90, 1024, 150)];
titleView.textAlignment = NSTextAlignmentCenter;
titleView.textColor = [UIColor whiteColor];
NSMutableAttributedString *title = [[NSMutableAttributedString alloc]initWithString:@"Welcome"];
UIFont *font = [UIFont fontWithName:@"Avenir-Light" size:60];
[title addAttribute:NSParagraphStyleAttributeName value:font range:NSMakeRange(0, title.length)];
titleView.attributedText = title;
[self.view addSubview:titleView];
UITextView
属性。 - jlhuertas