小编Irr*_*rrd的帖子

如何在Swift中将AnyObject类型转换为Int

我正在寻找在一个关键ArrayDictionarys,我想结果值转换成Int数值.这是我试过的.

if let result = lasrIDArray.flatMap( {$0["\(self.selectedTitle)"]} ).first {      
    print(result)

    if let number = result as? NSNumber {
        let tag = number.integerValue
        let currentScroll = view.viewWithTag(Int(api.selectedCatID)!) as! UIScrollView
        let lastImgVw = currentScroll.viewWithTag(tag) as! UIImageView
        print(lastImgVw.frame.origin.y)
    }
}
Run Code Online (Sandbox Code Playgroud)

但是if let number = result as? NSNumber没有按预期工作.转换此值的正确方法是什么?

int ios swift

9
推荐指数
1
解决办法
1万
查看次数

如何在 UILabel 中设置 2 行属性字符串

我想在我的UILabel. 它应该是2行。所以我制作了 2 个这样的属性字符串。

var myMutableTitle = NSMutableAttributedString(string: title!, attributes: [NSFontAttributeName:UIFont.init(name: fontBold, size: 15.0)!])
var mutDj=NSMutableAttributedString(string: dj!, attributes: [NSFontAttributeName:UIFont.init(name: font, size: 15.0)!])
Run Code Online (Sandbox Code Playgroud)

如何附加这两个属性字符串以显示在 2 行中,例如

Title
DJ name
Run Code Online (Sandbox Code Playgroud)

请帮我。谢谢

nsattributedstring ios swift

5
推荐指数
1
解决办法
5912
查看次数

标签 统计

ios ×2

swift ×2

int ×1

nsattributedstring ×1