[TIMOB-15624] iOS: AttributedString - Shadow attribute does not appear with the underline attribute for a label text
| GitHub Issue | n/a |
|---|---|
| Type | Bug |
| Priority | Medium |
| Status | Closed |
| Resolution | Not Our Bug |
| Resolution Date | 2013-10-31T20:59:51.000+0000 |
| Affected Version/s | n/a |
| Fix Version/s | n/a |
| Components | iOS |
| Labels | qe-3.2.0, qe-nfc |
| Reporter | Wilson Luu |
| Assignee | Ingo Muschenetz |
| Created | 2013-10-31T18:06:19.000+0000 |
| Updated | 2017-03-13T21:34:15.000+0000 |
Description
*Details:* Shadow attribute does not appear with the underline attribute for a label text.
*Steps to reproduce:*
1. Install the following app.js code to device:
var win = Ti.UI.createWindow({
backgroundColor: '#ddd',
});
win.open();
var text = 'Bacon ipsum dolor sit amet fatback leberkas salami sausage tongue strip steak. Andouille drumstick meatball boudin shank flank sausage, ribeye ham venison doner bacon ham hock. Appcelerator Titanium sucks rocks! Filet mignon ham pancetta, tail salami pork chop short ribs leberkas kielbasa t-bone tri-tip bresaola. Kevin beef ribs tail hamburger andouille filet mignon bresaola ham ham hock flank meatball pork chop corned beef';
var attr = Ti.UI.iOS.createAttributedString({
text: text,
attributes: [
// Underlines text
// Comment this out to see shadow
{
type: Ti.UI.iOS.ATTRIBUTE_UNDERLINES_TYLE,
value: Ti.UI.iOS.ATTRIBUTE_UNDERLINE_STYLE_SINGLE | Ti.UI.iOS.ATTRIBUTE_UNDERLINE_PATTERN_DASH_DOT_DOT,
range: [0, text.length]
},
// Sets a background color
{
type: Ti.UI.iOS.ATTRIBUTE_BACKGROUND_COLOR,
value: "blue",
range: [text.indexOf('Titanium'), ('Titanium').length]
},
// Sets a foreground color
{
type: Ti.UI.iOS.ATTRIBUTE_FOREGROUND_COLOR,
value: "white",
range: [0, text.length]
},
// Sets a background color
{
type: Ti.UI.iOS.ATTRIBUTE_BACKGROUND_COLOR,
value: "yellow",
range: [text.indexOf('rocks!'), ('rocks!').length]
},
// Sets a foreground color
{
type: Ti.UI.iOS.ATTRIBUTE_FOREGROUND_COLOR,
value: "black",
range: [text.indexOf('rocks!'), ('rocks!').length]
},
// Crossed out text
{
type: Ti.UI.iOS.ATTRIBUTE_STRIKETHROUGH_STYLE,
value: Ti.UI.iOS.ATTRIBUTE_UNDERLINE_STYLE_SINGLE,
range: [text.indexOf('sucks'), ('sucks').length]
},
// Creates a shadow
{
type: Ti.UI.iOS.ATTRIBUTE_SHADOW,
value: {
offset: {
width: 10,
height: 5
},
blurRadius: 1,
color: 'green'
},
range: [text.indexOf('Appcelerator'), ('Appcelerator').length]
}
]
});
var label = Ti.UI.createLabel({
left: 20,
right: 20,
height: Ti.UI.SIZE,
backgroundColor: 'red',
attributedString: attr
});
win.add(label);
*Actual:* A green shadow does not appear behind "Appcelerator" (see no_shadow.png).
*Expected:* A green shadow should appear behind "Appcelerator" (see shadow.png).
Attachments
| File | Date | Size |
|---|---|---|
| no_shadow.png | 2013-10-31T18:06:19.000+0000 | 96494 |
| shadow.png | 2013-10-31T18:06:19.000+0000 | 103492 |
Tested this in native Object-C app and can reproduce as well. This seems to be an Apple bug. Tested on iOS 7 Note: If the underline style is removed, then the shadow is visible.
- (void)viewDidLoad { [super viewDidLoad]; [[self view] setBackgroundColor:[UIColor lightGrayColor]]; NSString *text = @"Bacon ipsum dolor sit amet fatback leberkas salami sausage tongue strip steak. Andouille drumstick meatball boudin shank flank sausage, ribeye ham venison doner bacon ham hock. Appcelerator Titanium sucks rocks! Filet mignon ham pancetta, tail salami pork chop short ribs leberkas kielbasa t-bone tri-tip bresaola. Kevin beef ribs tail hamburger andouille filet mignon bresaola ham ham hock flank meatball pork chop corned beef"; UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(20, 20, 280, 500)]; [label setNumberOfLines:0]; [label setBackgroundColor:[UIColor redColor]]; NSMutableAttributedString *attr = [[NSMutableAttributedString alloc] initWithString:text]; [attr addAttribute: NSUnderlineStyleAttributeName value: [NSNumber numberWithInteger:NSUnderlineStyleSingle | NSUnderlinePatternDashDotDot] range: NSMakeRange(0, [text length]) ]; [attr addAttribute: NSBackgroundColorAttributeName value: [UIColor blueColor] range: [text rangeOfString:@"Titanium"] ]; [attr addAttribute: NSForegroundColorAttributeName value: [UIColor whiteColor] range: NSMakeRange(0, [text length]) ]; [attr addAttribute: NSBackgroundColorAttributeName value: [UIColor yellowColor] range: [text rangeOfString:@"rocks!"] ]; [attr addAttribute: NSForegroundColorAttributeName value: [UIColor blackColor] range: [text rangeOfString:@"rocks!"] ]; [attr addAttribute: NSStrikethroughStyleAttributeName value: [NSNumber numberWithInteger:NSUnderlineStyleSingle] range: [text rangeOfString:@"sucks"] ]; NSShadow *shadow = [[NSShadow alloc] init]; [shadow setShadowOffset:CGSizeMake(10, 5)]; [shadow setShadowBlurRadius:1]; [shadow setShadowColor:[UIColor greenColor]]; [attr addAttribute: NSShadowAttributeName value: shadow range: [text rangeOfString:@"Appcelerator"] ]; [label setAttributedText:attr]; [[self view] addSubview:label]; [label sizeToFit]; }Closing ticket as this is not our bug.