【发布时间】:2019-08-27 23:49:18
【问题描述】:
我正在实现一个设置游戏,其中我的卡片是由 NSAttributedString 作为属性标题组成的按钮。为了检查三个选定的卡片是否构成一组,我想比较每个属性字符串(它们是按钮上的属性标题)上的属性,因为每个属性都代表一个属性。这无法完成,因为我在比较它们时遇到了编译错误。
let at: [NSAttributedString.Key : Any] = [
.strokeColor : UIColor.blue,
.foregroundColor : UIColor.white,
.strokeWidth : -7.0,
.font : UIFont.systemFont(ofSize: 35)
]
let s = NSAttributedString(string: "●", attributes: at)
let attribute: [NSAttributedString.Key : Any] = [
.strokeColor : UIColor.blue,
.foregroundColor : UIColor.white,
.strokeWidth : -7.0,
.font : UIFont.systemFont(ofSize: 35)
]
let a = NSAttributedString(string: "▲", attributes: attribute)
if(s.attributes(at: 0, effectiveRange: nil) & (a.attributes(at: 0, effectiveRange: nil)) // ## Compilation Error: Any doesn't conform to Eqautable Protocol ##
【问题讨论】:
-
请在问题描述中添加您遇到的编译错误。谢谢
标签: swift4.2 nsattributedstringkey