UILabel 字母被截断

发布于 2024-11-30 11:36:00 字数 1086 浏览 1 评论 0原文

在此处输入图像描述我正在尝试在 UILabel 中使用特殊字符。但它正在取消标签。我放置了红色背景来显示标签边缘的位置。有什么原因可能会发生这种情况吗?我将 maskToBounds 和 ClipToBounds 设置为 NO;

CGSize lblSize = [FontHelper sizeForText:text withFont:[self getBodyFont] withWidth:kColumnWidth andNumberOfLines:1000];
            UILabel*lbl = [[UILabel alloc] initWithFrame:CGRectMake(x, 
                                                                    y + body.frame.size.height - columnHeight - kBottomMargin, 
                                                                    kColumnWidth, 
                                                                    lblSize.height)];
            lbl.clipsToBounds = NO;
            lbl.layer.masksToBounds = NO;
            lbl.text = text;
            lbl.backgroundColor = [UIColor redColor];
            lbl.font = [self getBodyFont];
            lbl.textColor = [UIColor blackColor];
            lbl.numberOfLines = 0;
            lbl.textAlignment = UITextAlignmentLeft;
            lbl.lineBreakMode = UILineBreakModeWordWrap;

enter image description hereI am trying to use a special character in the UILabel. But it is chopping off the labels. I put in a red background to show where the edge of the label is. Any reason why this may be happening? I have maskToBounds and clipToBounds set to NO;

CGSize lblSize = [FontHelper sizeForText:text withFont:[self getBodyFont] withWidth:kColumnWidth andNumberOfLines:1000];
            UILabel*lbl = [[UILabel alloc] initWithFrame:CGRectMake(x, 
                                                                    y + body.frame.size.height - columnHeight - kBottomMargin, 
                                                                    kColumnWidth, 
                                                                    lblSize.height)];
            lbl.clipsToBounds = NO;
            lbl.layer.masksToBounds = NO;
            lbl.text = text;
            lbl.backgroundColor = [UIColor redColor];
            lbl.font = [self getBodyFont];
            lbl.textColor = [UIColor blackColor];
            lbl.numberOfLines = 0;
            lbl.textAlignment = UITextAlignmentLeft;
            lbl.lineBreakMode = UILineBreakModeWordWrap;

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

涫野音 2024-12-07 11:36:00

我想我找到了解决方案。客户给了我 Word 文档中的上述文本,我将其复制并粘贴到该文件中。点和文本之间的空格看起来是一个空格,但实际上是其他特殊字符。所以复制/粘贴暴露了它丑陋的头。

I think I found the solution. The client had give me the above text in a Word Doc and I had copy and pasted into the file. The space between the dot and the text appeared to be a space but was other special character. So copy/paste flared its ugly head.

吃不饱 2024-12-07 11:36:00

对于任何其他偶然发现这个问题的人,我也遇到了同样的问题,在我的例子中,UILabel 中有一些制表符,这导致了相同的效果。

For anyone else who stumbles on this question, I had the same problem and in my case there were a few tab characters in the UILabel, which caused the same effect.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文