반응형
📄 Swift Source Code
import UIKit
// MARK: - Extension NSAttributedString Image Protocol
extension NSMutableAttributedString {
func appendImage(_ image: UIImage) {
// MARK: Create our NSTextAttachment.
let imageAttchment: NSTextAttchment = NSTextAttchment()
imageAttchment.image = image
// MARK: Wrap the attachment in its own attributed string so we can append it.
let strImage: NSAttributedString = NSAttributedString(attachment: imageAttchment)
self.append(strImage)
}
}
🚀 REFERENCE
반응형
'# 애플 [Apple] > iOS' 카테고리의 다른 글
[iOS] UserDefaults (0) | 2019.08.01 |
---|---|
[iOS] UIScrollView 스크롤 시 키보드 내리기 (Dismissing the keyboard in a UIScrollView) (0) | 2019.08.01 |
[iOS] GestureRecognizer이 반응하지 않을 경우 (GestureRecognizer not responding to tap) (0) | 2019.07.03 |
[iOS] 테이블 뷰 셀 밀어서 삭제하기 (Add swipe to delete UITableViewCell) (0) | 2019.07.02 |
[iOS] UserDefaults (How to save user settings using UserDefaults) (0) | 2019.07.02 |
댓글