Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Label background color #1816

Closed
wants to merge 1 commit into from

3 participants

mitchell amihod Marshall Culpepper Neeraj Gupta
mitchell amihod

Problem: You couldn't assign a backgroundColor directly to a label. It is initialized to clear.

This can lead to performance penalty, as described in this post: http://blogs.captechconsulting.com/blog/john-szumski/performance-tuning-older-ios-devices

Solution: Enabled setBackgroundColor_ for label. Performs as before - if no color given, defaults to clear (transparent) else assigns bg color to the label directly. If dev's care, they can take the time to set the proper label backgroundColor now.

mitchell amihod meeech Fix for Label Blending Issue:
Problem: You couldn't assign a backgroundColor directly to a label. It is initialized to clear. This can lead to performance penalty, as described in this post: http://blogs.captechconsulting.com/blog/john-szumski/performance-tuning-older-ios-devices
Solution: Enabled setBackgroundColor_ for label. Performs as before - if no color given, defaults to clear (transparent) else assigns bg color to the label directly.
1338566
mitchell amihod

Only gotcha I can think that would need to be accounted for here (beyond my ability) is when using backgroundImage, then would probably want to force the label color to clear again, since it seems bgimage stuff is being applied to a subview, not to the label itself.

But the substance of the fix still stands - would be good to have the ability to assign label color directly.

Marshall Culpepper

@meeech

Correct me if I'm wrong, but we already expose setBackgroundColor for all TiUIViews in TiUIView.m:
https://github.com/appcelerator/titanium_mobile/blob/master/iphone/Classes/TiUIView.m#L403

mitchell amihod

Hi marshall,
Yes. But this is specific to how labels are being handled in Ti.
Basically, its defaulted to clear. When you call setBackgroundColor on a label, its actually changing the underlying view containing the label. The BG color on the label remains clear. So it means labels always are being blended, and there's no way to stop it.

mitchell amihod

Here's an illustration. you can see all the labels in in my table are red - being blended. Even when the backgroundColor on each label is explicitly set to the same bg color as the table row.

Blend Screen Shot

Neeraj Gupta
Owner

@Mitchell - We need a signed CLA in place before we can accept a PR. Did you sign one? I could not find it in our database.

mitchell amihod
mitchell amihod

done.

Neeraj Gupta
Owner

Signed CLA is in place.

Neeraj Gupta
Owner

@meech - Please file a JIRA ticket with a test case and we will process this PR at a priority.

Neeraj Gupta
Owner

@Meeech - Do you plan to file a JIRA ticket with a test case to process this PR?

mitchell amihod
meeech commented

@negupta By test case, do you just mean an app.js example?
At this point, i think best to just close this one for 1.8.2. I'll have a look at fixing it up for 2.x, and take things like backgroundImage into account.

mitchell amihod meeech closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Mar 23, 2012
mitchell amihod meeech Fix for Label Blending Issue:
Problem: You couldn't assign a backgroundColor directly to a label. It is initialized to clear. This can lead to performance penalty, as described in this post: http://blogs.captechconsulting.com/blog/john-szumski/performance-tuning-older-ios-devices
Solution: Enabled setBackgroundColor_ for label. Performs as before - if no color given, defaults to clear (transparent) else assigns bg color to the label directly.
1338566
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 10 additions and 0 deletions. Show diff stats Hide diff stats

  1. +10 0 iphone/Classes/TiUILabel.m
10 iphone/Classes/TiUILabel.m
@@ -6,6 +6,7 @@
6 6 */
7 7 #ifdef USE_TI_UILABEL
8 8
  9 +#import "TiColor.h"
9 10 #import "TiUILabel.h"
10 11 #import "TiUILabelProxy.h"
11 12 #import "TiUtils.h"
@@ -175,6 +176,15 @@ -(void)setMinimumFontSize_:(id)size
175 176
176 177 }
177 178
  179 +-(void)setBackgroundColor_:(id)value
  180 +{
  181 + if (value!=nil)
  182 + {
  183 + TiColor *color = [TiUtils colorValue:value];
  184 + [[self label] setBackgroundColor:[color _color]];
  185 + }
  186 +}
  187 +
178 188 -(void)setBackgroundImage_:(id)url
179 189 {
180 190 if (url != nil) {

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.