开发者

Possible UITableViewCell UILabel Compositing Anomaly

Consider a UITableViewCell with a style of UITableViewCellStyleDefault, set in tableView:cellForRowAtIndexPath:, and a gradient background, set in tableView:willDisplayCell:forRowAtIndexPath:.

When this is rendered, the textLabel will blend in just fine with the gradient, and highlighting works just as well.

Now, what if we keep everything identical, but change the cell style to UITableViewCellStyleSubtitle? In my case, the textLabel and detailTextLabel no longer blend at all! They take on ... some other color. Not too far off from the colors in the gradient, but it simply doesn't blend. Change the style back to default, and all is well.

Now, I realize I could set the labels to clearColor in ...willDisplayCell... but I've been told over and over again, "Don't do that! Leave them colors alone."

Perhaps I have to do that as a workaround? Or might something else 开发者_开发百科be amiss? Clues welcome/appreciated!


A work around would be to use NSString's drawInRect function. You could use the NSString sizeWithFont:forWidth:lineBreakMode: method to calculate the rect size and then draw the strings out that way.

more about string sizes and drawing here on apples docs site.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜