我有一个自定义的UISegmentedControl对象,它显示为
#import "redSegmentedControl.h"
@implementation redSegmentedControl
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
[self setBackgroundImage:[UIImage imageNamed:@"nev.png"] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
[self setBackgroundImage:[[UIImage imageNamed:@"nev_hover.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)] forState:UIControlStateSelected barMetrics:UIBarMetricsDefault];
[self setDividerImage:[UIImage imageNamed:@"nev_sep.png"] forLeftSegmentState:UIControlStateNormal rightSegmentState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
[self setDividerImage:[UIImage imageNamed:@"nev_sep.png"] forLeftSegmentState:UIControlStateNormal rightSegmentState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
[self setDividerImage:[UIImage imageNamed:@"nev_sep.png"] forLeftSegmentState:UIControlStateNormal rightSegmentState:UIControlStateSelected barMetrics:UIBarMetricsDefault];
self.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"nev_hover.png"]];
NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys:[UIFont fontWithName:@"LatinBold13" size:bool_isEnglish?15.0f:10.0f], UITextAttributeFont, [UIColor whiteColor], UITextAttributeTextColor, [UIColor blackColor], UITextAttributeTextShadowColor, nil];
[self setTitleTextAttributes:attributes forState:UIControlStateNormal];
[self setTitleTextAttributes:attributes forState:UIControlStateSelected];
}
return self;
}
@end
初始化后,如果我设置了ENGLISH文本,则显示正常。当我放入阿拉伯语文本时,它会突破性格。
[topMenu setTitle:@"Featured" forSegmentAtIndex:0];
[topMenu setTitle:@"متميز" forSegmentAtIndex:0];
这里ENGLISH TEXT显示完美,但阿拉伯文TEXT逐字逐句打破并显示如下图像
我阅读了Apple文档,但没有关于String及其语言的内容。 我删除了额外的格式,但没有用。
我注意到了
NSString * string = @"االْحَمْدُ لِلَّهِ رَبِّ الْعَالَمِينَ"; //Any Arabic line
NSLog(@"%@",string);
它在LOG中看起来很好,但是当我将它放在段控件上时,它会将其分解为字符并显示。
我也尝试过编码,但没用。
预期的原因是什么,任何帮助!!!!
由于
答案 0 :(得分:1)
NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys:[UIFont fontWithName:@"Arial" size:bool_isEnglish?15.0f:12.0f], UITextAttributeFont, [UIColor whiteColor], UITextAttributeTextColor, [UIColor blackColor], UITextAttributeTextShadowColor, nil];
只有 FONT NAME 才会产生问题。我把它从“LatinBold13”改为“Arial”。它的工作正常现在。
由于