jjzjj

NSUnderlineStyle

全部标签

ios - 如何使大写字母的 UILabel NSUnderlineStyle.StyleSingle attributedString 居中

我有以下方法,适用于带有大写和小写字母的标签。funcstrikeThroughLabel(label:UILabel){letattributedString=NSAttributedString(string:label.text!,attributes:[NSStrikethroughStyleAttributeName:NSUnderlineStyle.StyleSingle.rawValue])label.attributedText=attributedString}问题是对于包含所有大写字母的标签,删除线不是垂直居中的。解决这个相当麻烦的问题的最简单方法是什么?

ios - NSUnderlineStyle 属性名称 下划线间距

我希望下划线像任何其他正常的下划线机制一样位于文本下方。但是,对于NSAttributed字符串,它会留下带有“g's”和“y's”的漏洞例子:它应该是怎样的:如何增加下划线和标签之间的间距? 最佳答案 无法使用NSAttributedString或CoreText来控制该行为(除了自己绘制下划线)。NSAttributedString对此没有选择(和CoreTexthasn'tgotone,either)。在Apple系统上,第一个版本(有间隙)是“预期”行为,因为它是Apple提供并在整个系统(以及Safari、TextEdit

ios - NSUnderlineStyle 属性名称 下划线间距

我希望下划线像任何其他正常的下划线机制一样位于文本下方。但是,对于NSAttributed字符串,它会留下带有“g's”和“y's”的漏洞例子:它应该是怎样的:如何增加下划线和标签之间的间距? 最佳答案 无法使用NSAttributedString或CoreText来控制该行为(除了自己绘制下划线)。NSAttributedString对此没有选择(和CoreTexthasn'tgotone,either)。在Apple系统上,第一个版本(有间隙)是“预期”行为,因为它是Apple提供并在整个系统(以及Safari、TextEdit

swift - 设置 NSUnderlineStyle 导致无法识别的选择器异常

我正在尝试使用NSAttributed字符串为字符串加下划线。出于某种原因,我的台词导致了异常:-[_SwiftValue_getValue:forType:]:unrecognizedselectorsenttoinstance结果应该用于UITableView中的UILabel,并根据需要创建。这是代码:attributedString=NSMutableAttributedString(string:message)ifletactor=event.actor{letattributes=[NSUnderlineStyleAttributeName:NSUnderlineStyl

swift - 设置 NSUnderlineStyle 导致无法识别的选择器异常

我正在尝试使用NSAttributed字符串为字符串加下划线。出于某种原因,我的台词导致了异常:-[_SwiftValue_getValue:forType:]:unrecognizedselectorsenttoinstance结果应该用于UITableView中的UILabel,并根据需要创建。这是代码:attributedString=NSMutableAttributedString(string:message)ifletactor=event.actor{letattributes=[NSUnderlineStyleAttributeName:NSUnderlineStyl

ios - 在 Swift 中将 NSUnderlineStyle.PatternDash 添加到 NSAttributedString?

我正在尝试为我的Swift应用程序中的某些文本添加下划线。这是我目前的代码:lettext=NSMutableAttributedString(string:self.currentHome.name)letattrs=[NSUnderlineStyleAttributeName:NSUnderlineStyle.PatternDash]text.addAttributes(attrs,range:NSMakeRange(0,text.length))homeLabel.attributedText=text但我在text.addAttributes行收到此错误:NSStringisn

ios - 在 Swift 中将 NSUnderlineStyle.PatternDash 添加到 NSAttributedString?

我正在尝试为我的Swift应用程序中的某些文本添加下划线。这是我目前的代码:lettext=NSMutableAttributedString(string:self.currentHome.name)letattrs=[NSUnderlineStyleAttributeName:NSUnderlineStyle.PatternDash]text.addAttributes(attrs,range:NSMakeRange(0,text.length))homeLabel.attributedText=text但我在text.addAttributes行收到此错误:NSStringisn

ios - 如何使用 NSUnderlineStyle.PatternDot

我正在尝试使用带有虚线下划线的NSMutableAttributedString下面是我的代码,但似乎没有一个模式有效,我是否遗漏了什么?varstr:NSMutableAttributedString=NSMutableAttributedString(string:"HelloWorld")str.addAttribute(NSUnderlineStyleAttributeName,value:NSNumber(integer:(NSUnderlineStyle.PatternDot).rawValue),range:NSMakeRange(0,str.length))

ios - 如何定义自定义 NSUnderlineStyle

查看NSLayoutManager的文档,特别是drawUnderlineForGlyphRange:underlineType:baselineOffset:lineFragmentRect:lineFragmentGlyphRange:containerOrigin:方法,我注意到以下内容(强调我的):underlineValThestyleofunderliningtodraw.ThisvalueisamaskderivedfromthevalueforNSUnderlineStyleAttributeName—forexample,(NSUnderlinePatternDash