设置UITextView.textColor无效?

时间:2015-08-13 10:38:34

标签: ios uitableview uitextview

我在UITextView中有一个简单的(没有归属文字)UITableViewCell。我在主故事板中将UITextView textColor设置为'ColorSwatch.Clay'(接近白色的颜色)(背景为深色)。
 无效:文字仍为黑色。

即使在设置文字之前在单元格中明确设置textColor也无效。

请帮助,这让我疯了!这可能是令人难以置信的愚蠢,但我宁愿感到愚蠢,保持理智。

更新:以下是一些代码:

UITableViewDataSource:

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    let reviewCell = self.reviewTable.dequeueReusableCellWithIdentifier("ReviewTableViewCell", forIndexPath: indexPath) as! ReviewTableViewCell
    reviewCell.configureFor(reviewManager[indexPath.row])
    return reviewCell
}

ReviewTableViewCell:

@IBOutlet weak var rating: StarRating!
@IBOutlet weak var authorAndDateLabel: UILabel!
@IBOutlet weak var reviewTextArea: UITextView!

func configureFor(review: Review) {
    rating.rating = review.rating

    let authorName = review.author["fullname"] as? String ?? review.author.username
    let date = NSDateFormatter.localizedStringFromDate(review.updatedAt!, dateStyle: .ShortStyle, timeStyle: .NoStyle)

    // For some reason the textColor specified in the storyboard is overriden somewhere...
    reviewTextArea.textColor = ColorSwatch.Clay

    reviewTextArea.text = review.text
}

2 个答案:

答案 0 :(得分:0)

就是这样。

reviewTextArea.textColor会覆盖您的textColor

ColorSwatch.Clay是白色以外的其他颜色。

因此,以编程方式将白色设置为reviewTextArea.textColor

希望这有帮助。

答案 1 :(得分:0)

案件结案。我不能说出了什么问题,但我不得不重构UI:删除文本视图,再添加一个......并且没有一切都很好。抱歉,麻烦。