3

从 iOS 7 开始,现在支持阿拉伯字体,但是当我使用:

   lbl.font=[UIFont fontWithName:@"Scheherazade" size:33];

文字到达边缘,UILabel有些单词无法阅读!

这个问题怎么解决??这是描述我的问题。照片

这是我的代码:

lbl  = [[UILabel alloc]initWithFrame:CGRectMake(20, 50, 280, 320)];
lbl.text = @"شِّرِ ٱلَّذِينَ ءَامَنُوا۟ وَعَمِلُوا۟ ٱلصَّٰلِحَٰتِ أَنَّ لَهُمْ جَنَّٰتٍۢ تَجْرِى مِن تَحْتِهَا ٱلْأَنْهَٰرُ ۖ كُلَّمَا رُزِقُوا۟ مِنْهَا مِن ثَمَرَةٍۢ رِّزْقًۭا ۙ قَالُوا۟ هَٰذَا ٱلَّذِى رُزِقْنَا مِن قَبْلُ ۖ وَأُتُوا۟ بِهِۦ مُتَشَٰبِهًۭا ۖ وَلَهُمْ فِيهَآ أَزْوَٰجٌۭ مُّطَهَّرَةٌۭ ۖ وَهُمْ فِيهَا خَٰلِدُونَ";
lbl.font=[UIFont fontWithName:@"Scheherazade" size:33.0];
lbl.backgroundColor = [UIColor whiteColor];
lbl.lineBreakMode = NSLineBreakByCharWrapping;
[self.view addSubview:lbl];
lbl.numberOfLines = 0;
lbl.textAlignment = NSTextAlignmentCenter;
4

5 回答 5

0

我刚刚更改了换行模式“NSLineBreakByWordWrapping”。我认为这是由于阿拉伯文字而出现的问题。

UILabel * lbl = [[UILabel alloc]initWithFrame:CGRectMake(20, 50, 280, 320)];

lbl.text = @"شِّرِ ٱلَّذِينَ ءَامَنُوا۟ وَعَمِلُوا۟ ٱلصَّٰلِحَٰتِ أَنَّ لَهُمْ جَنَّٰتٍۢ تَجْرِى مِن تَحْتِهَا ٱلْأَنْهَٰرُ ۖ كُلَّمَا رُزِقُوا۟ مِنْهَا مِن ثَمَرَةٍۢ رِّزْقًۭا ۙ قَالُوا۟ هَٰذَا ٱلَّذِى رُزِقْنَا مِن قَبْلُ ۖ وَأُتُوا۟ بِهِۦ مُتَشَٰبِهًۭا ۖ وَلَهُمْ فِيهَآ أَزْوَٰجٌۭ مُّطَهَّرَةٌۭ ۖ وَهُمْ فِيهَا خَٰلِدُونَ";
lbl.font=[UIFont fontWithName:@"Scheherazade" size:33.0];
lbl.backgroundColor = [UIColor white];
lbl.lineBreakMode = NSLineBreakByWordWrapping;
[self.view addSubview:lbl];
lbl.numberOfLines = 0;
lbl.textAlignment = NSTextAlignmentCenter;
于 2013-11-13T08:20:14.627 回答
0

我在 iOS 7 中看到了同样的问题。我认为有一个错误NSLineBreakByCharWrapping总是视为NSLineBreakByWordWrapping. 我已经提交给苹果了。

于 2013-10-09T20:35:30.663 回答
0

尝试将UILabel's设置preferredMaxLayoutWidth为其父视图的宽度(可选择使用左/右填充)。

于 2013-10-14T18:35:21.100 回答
0

I was having a similar problem where my custom font was cut off on the bottom (especially in iOS 7), and I found a few answers on this post to be quite helpful where I edited the font file directly and changed the ascender and/or descender attributes.

Custom installed font not displayed correctly in UILabel

In your case there might be other attributes in that font file that you can edit to prevent it from being cut off on the left and ride sides.

于 2013-10-14T18:29:04.887 回答
-2

发现您的问题实际上字体大小并没有随着您lbl.font=[UIFont fontWithName:@"Scheherazade" size:33.0];尝试使用此代码调整字体大小而改变

lbl.font= [UIFont systemFontOfSize:10];

我已经更新了我的代码,现在我可以看到完整的文本了

UILabel *lbl  = [[UILabel alloc]initWithFrame:CGRectMake(20, 0, 280, 320)];
lbl.text = @"شِّرِ ٱلَّذِينَ ءَامَنُوا۟ وَعَمِلُوا۟ ٱلصَّٰلِحَٰتِ أَنَّ لَهُمْ جَنَّٰتٍۢ تَجْرِى مِن تَحْتِهَا ٱلْأَنْهَٰرُ ۖ كُلَّمَا رُزِقُوا۟ مِنْهَا مِن ثَمَرَةٍۢ رِّزْقًۭا ۙ قَالُوا۟ هَٰذَا ٱلَّذِى رُزِقْنَا مِن قَبْلُ ۖ وَأُتُوا۟ بِهِۦ مُتَشَٰبِهًۭا ۖ وَلَهُمْ فِيهَآ أَزْوَٰجٌۭ مُّطَهَّرَةٌۭ ۖ وَهُمْ فِيهَا خَٰلِدُونَ";
lbl.font=[UIFont fontWithName:@"Scheherazade" size:33.0];
lbl.backgroundColor = [UIColor whiteColor];
//lbl.lineBreakMode = NSLineBreakByCharWrapping;
[self.view addSubview:lbl];
lbl.numberOfLines = 0;
lbl.textAlignment = NSTextAlignmentCenter;

截图

于 2013-09-24T12:56:10.307 回答