此代码通过USB端口在模拟器和连接的设备中工作。当应用程序编译以进行分发时(目标:IOS 6.1,Xcode 5.1.1)并以.ipa
下载时,它不起作用知道为什么吗?有没有人见过这个?有解决方法吗?
#import "UILabel+UILabel_decoratedText.h"
@implementation UILabel (UILabel_decoratedText)
+ (UILabel *)decoratedText:(NSString *)string
font:(UIFont *)font
color:(UIColor *)color
container:(CGRect)container
shadowOffset:(CGSize)shadowOffsetSize
shadowColor:(UIColor *)shadowColor
shadowBlurRadius:(CGFloat)blurRadius
tag:(NSUInteger)tagInteger
{
CGSize size = [string sizeWithFont:font constrainedToSize:container.size lineBreakMode:NSLineBreakByWordWrapping];
UILabel *label = [[UILabel alloc]
initWithFrame:CGRectMake(container.origin.x, container.origin.y, container.size.width, size.height)];
label.text = string;
label.font = font;
label.textColor = color;
label.textAlignment = NSTextAlignmentCenter;
label.numberOfLines = 0;
label.lineBreakMode = NSLineBreakByWordWrapping;
label.backgroundColor = [UIColor clearColor];
label.tag = tagInteger;
NSShadow *shadow = [NSShadow new];
[shadow setShadowColor: shadowColor];
[shadow setShadowOffset: shadowOffsetSize]; // CGSizeMake(-1.0f, 1.0f)
[shadow setShadowBlurRadius: blurRadius];
NSAttributedString *attributedString;
if ((string != nil) && (![string isEqualToString:@""])) {
NSDictionary *dictionary = @{ NSForegroundColorAttributeName:color,
NSFontAttributeName : font,
NSShadowAttributeName: shadow
};
attributedString = [[NSAttributedString alloc] initWithString:string attributes:dictionary];
label.attributedText = attributedString;
}
return label;
}
@end
答案 0 :(得分:2)
在使用多行UILabel和NSAttributedString遇到一堆问题后,我将UILabel更改为UITextView,一切正常。您可以搜索SO和Google以获取UILabel,NSAttributedString和问题,并且您会获得一些点击。