我正在实现一个设置游戏,其中我的卡片是由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 ##