[iOS] Bullet Point List 만들기

kimdocs...📄·2021년 9월 7일
0
extension UILabel {
    func setBulletPointList(strings: [String]) {
        let paragraphStyle = NSMutableParagraphStyle()
        paragraphStyle.headIndent = 15
        paragraphStyle.minimumLineHeight = 24
        paragraphStyle.maximumLineHeight = 24
        paragraphStyle.tabStops = [NSTextTab(textAlignment: .left, location: 15)]

        let stringAttributes = [
            NSAttributedString.Key.font: YDSFont.body1,
            NSAttributedString.Key.foregroundColor: YDSColor.textPrimary,
            NSAttributedString.Key.paragraphStyle: paragraphStyle,
        ]

        let string = strings.map { "•\t\($0)" }.joined(separator: "\n")

        attributedText = NSAttributedString(string: string,
                                            attributes: stringAttributes)
    }
}
profile
👩‍🌾 GitHub: ezidayzi / 📂 Contact: ezidayzi@gmail.com

0개의 댓글