Swift 3 display all apple emojis in a view

2019-02-20 18:32发布

I want to display all the apple emojis in a view in same sequence as displayed here https://emojipedia.org/apple/ with the help of their unicode.

I used the following code to implement this.

let emojiRanges = [
        0x1F601...0x1F64F,
        0x2702...0x27B0,
        0x1F680...0x1F6C0,
        0x1F170...0x1F251
    ]

    for range in emojiRanges {
        for i in range {
            let c = UnicodeScalar(i)
            print(c ?? "")
        }
    }

But through this I am not getting expected result. Most of the emojis are missing in between. Please suggest an appropriate solution for this.

Thanks.

标签: ios swift swift3
1条回答
干净又极端
2楼-- · 2019-02-20 19:03

Swift 3.0 code...

  let emojiRanges = [
            0x1F601...0x1F64F,
            0x2702...0x27B0,
            0x1F680...0x1F6C0,
            0x1F170...0x1F251
        ]
        var emojiarray:[String] = []
        for range in emojiRanges {
            for i in range {
                let c = String(UnicodeScalar(i)!)
                emojiarray.append(c)
            }
        }
    print(emojiarray)// ["                                                                    
查看更多
登录 后发表回答