Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Label background color #1816

Closed
wants to merge 1 commit into from

3 participants

@meeech

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.

@meeech 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
@meeech

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

@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

@meeech

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.

@meeech

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

@negupta
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.

@meeech
@meeech

done.

@negupta
Owner

Signed CLA is in place.

@negupta
Owner

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

@negupta
Owner

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

@meeech

@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.

@meeech meeech closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 23, 2012
  1. @meeech

    Fix for Label Blending Issue:

    meeech authored
    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.
This page is out of date. Refresh to see the latest.
Showing with 10 additions and 0 deletions.
  1. +10 −0 iphone/Classes/TiUILabel.m
View
10 iphone/Classes/TiUILabel.m
@@ -6,6 +6,7 @@
*/
#ifdef USE_TI_UILABEL
+#import "TiColor.h"
#import "TiUILabel.h"
#import "TiUILabelProxy.h"
#import "TiUtils.h"
@@ -175,6 +176,15 @@ -(void)setMinimumFontSize_:(id)size
}
+-(void)setBackgroundColor_:(id)value
+{
+ if (value!=nil)
+ {
+ TiColor *color = [TiUtils colorValue:value];
+ [[self label] setBackgroundColor:[color _color]];
+ }
+}
+
-(void)setBackgroundImage_:(id)url
{
if (url != nil) {
Something went wrong with that request. Please try again.