Last active
August 25, 2017 19:36
-
-
Save harrysummers/12c9acb6b1fe0d533ac219d26afec5d4 to your computer and use it in GitHub Desktop.
Alamofire with JSQMessagesViewController
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import AlamofireImage | |
import JSQMessagesViewController | |
import NVActivityIndicatorView | |
class AsyncPhotoMediaItem: JSQPhotoMediaItem { | |
var asyncImageView: UIImageView! | |
var url : URL? | |
override init!(maskAsOutgoing: Bool) { | |
super.init(maskAsOutgoing: maskAsOutgoing) | |
} | |
init(withURL url: URL?, frame : CGRect) { | |
super.init() | |
appliesMediaViewMaskAsOutgoing = true | |
asyncImageView = UIImageView() | |
asyncImageView.frame = frame | |
asyncImageView.contentMode = .scaleAspectFill | |
asyncImageView.clipsToBounds = true | |
asyncImageView.layer.cornerRadius = 20 | |
asyncImageView.backgroundColor = UIColor.jsq_messageBubbleLightGray() | |
if let url = url { | |
asyncImageView.af_setImage(withURL: url) | |
} else { | |
asyncImageView.image = nil | |
} | |
} | |
override func mediaView() -> UIView! { | |
return asyncImageView | |
} | |
override func mediaViewDisplaySize() -> CGSize { | |
return asyncImageView.frame.size | |
} | |
required init?(coder aDecoder: NSCoder) { | |
fatalError("init(coder:) has not been implemented") | |
} | |
func loadUrl(_ tempUrl: URL?) { | |
url = tempUrl | |
if (url != nil) { | |
asyncImageView.af_setImage(withURL: url!) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi harrysummers
all images align right