@@ -22,7 +22,7 @@ import UIKit
2222extension ASAttributedString {
2323
2424 public enum Attachment {
25- case image( Image , bounds: CGRect )
25+ case image( ASImage , bounds: CGRect )
2626 case data( Data , type: String )
2727 case file( FileWrapper )
2828 case attachment( NSTextAttachment )
@@ -55,11 +55,11 @@ extension ASAttributedString {
5555
5656 public let style : Style
5757
58- public static func image( _ image: Image , _ style: Style = . original( ) ) -> ImageAttachment {
58+ public static func image( _ image: ASImage , _ style: Style = . original( ) ) -> ImageAttachment {
5959 return . init( image, style)
6060 }
6161
62- init ( _ image: Image ? , _ style: Style = . original( ) ) {
62+ init ( _ image: ASImage ? , _ style: Style = . original( ) ) {
6363 self . style = style
6464 super. init ( data: nil , ofType: nil )
6565 self . image = image
@@ -110,7 +110,7 @@ extension ASAttributedString {
110110 public static var Loader : AsyncImageAttachmentLoader . Type = AsyncImageAttachmentURLSessionLoader . self
111111
112112 public let url : URL ?
113- public let placeholder : Image ?
113+ public let placeholder : ASImage ?
114114
115115 private weak var textContainer : NSTextContainer ?
116116
@@ -121,11 +121,11 @@ extension ASAttributedString {
121121 /// - url: 图片链接
122122 /// - placeholder: 占位图
123123 /// - Returns: 异步图片附件
124- public static func image( _ url: URL ? , placeholder: Image ? = nil , _ style: Style = . original( ) ) -> AsyncImageAttachment {
124+ public static func image( _ url: URL ? , placeholder: ASImage ? = nil , _ style: Style = . original( ) ) -> AsyncImageAttachment {
125125 return . init( url, placeholder, style)
126126 }
127127
128- init ( _ url: URL ? , _ placeholder: Image ? , _ style: Style = . original( ) ) {
128+ init ( _ url: URL ? , _ placeholder: ASImage ? , _ style: Style = . original( ) ) {
129129 self . url = url
130130 self . placeholder = placeholder
131131 self . loader = AsyncImageAttachment . Loader. init ( )
@@ -155,7 +155,7 @@ extension ASAttributedString {
155155 }
156156 }
157157
158- public override func image( forBounds imageBounds: CGRect , textContainer: NSTextContainer ? , characterIndex charIndex: Int ) -> Image ? {
158+ public override func image( forBounds imageBounds: CGRect , textContainer: NSTextContainer ? , characterIndex charIndex: Int ) -> ASImage ? {
159159 self . textContainer = textContainer
160160 if image == placeholder {
161161 loadImage ( )
@@ -186,7 +186,7 @@ extension ASAttributedString {
186186 self . view = view
187187 self . style = style
188188 super. init ( data: nil , ofType: nil )
189- self . image = Image ( )
189+ self . image = ASImage ( )
190190 }
191191
192192 required init ? ( coder: NSCoder ) {
@@ -335,7 +335,7 @@ fileprivate extension ASAttributedString.Attachment.Alignment {
335335 /// - lineHeight: 行高
336336 /// - Returns: 位置坐标
337337 func point( _ size: CGSize , with lineHeight: CGFloat ) -> CGPoint {
338- var font = Font . systemFont ( ofSize: 18 )
338+ var font = ASFont . systemFont ( ofSize: 18 )
339339 let fontSize = font. pointSize / ( abs ( font. descender) + abs( font. ascender) ) * lineHeight
340340 font = . systemFont( ofSize: fontSize)
341341
@@ -421,7 +421,7 @@ public protocol AsyncImageAttachmentLoader: NSObject {
421421 /// - Parameters:
422422 /// - url: 链接
423423 /// - completion: 完成回调
424- func loadImage( with url: URL , completion: @escaping ( Swift . Result < Image , Swift . Error > ) -> Void )
424+ func loadImage( with url: URL , completion: @escaping ( Swift . Result < ASImage , Swift . Error > ) -> Void )
425425 /// 取消加载
426426 func cancel( )
427427}
@@ -434,7 +434,7 @@ public class AsyncImageAttachmentURLSessionLoader: NSObject, AsyncImageAttachmen
434434 return downloadTask != nil
435435 }
436436
437- public func loadImage( with url: URL , completion: @escaping ( Result < Image , Error > ) -> Void ) {
437+ public func loadImage( with url: URL , completion: @escaping ( Result < ASImage , Error > ) -> Void ) {
438438 downloadTask = URLSession . shared. dataTask ( with: url) {
439439 [ weak self] ( data, response, error) in
440440 guard let self = self else { return }
@@ -446,7 +446,7 @@ public class AsyncImageAttachmentURLSessionLoader: NSObject, AsyncImageAttachmen
446446 }
447447 return
448448 }
449- guard let image = Image ( data: data) else {
449+ guard let image = ASImage ( data: data) else {
450450 DispatchQueue . main. async {
451451 completion ( . failure( NSError ( domain: " Unable to create image " , code: - 2 ) ) )
452452 }
0 commit comments