set user for avatar

This commit is contained in:
nixzhu
2015-08-14 15:25:58 +08:00
parent 7e326963e1
commit 178b8eca43
2 changed files with 17 additions and 7 deletions
@@ -670,11 +670,13 @@ class ConversationViewController: BaseViewController {
let friendRequestViewLeading = NSLayoutConstraint(item: friendRequestView, attribute: .Leading, relatedBy: .Equal, toItem: view, attribute: .Leading, multiplier: 1, constant: 0)
let friendRequestViewTrailing = NSLayoutConstraint(item: friendRequestView, attribute: .Trailing, relatedBy: .Equal, toItem: view, attribute: .Trailing, multiplier: 1, constant: 0)
let friendRequestViewTop = NSLayoutConstraint(item: friendRequestView, attribute: .Top, relatedBy: .Equal, toItem: view, attribute: .Top, multiplier: 1, constant: 64)
let friendRequestViewHeight = NSLayoutConstraint(item: friendRequestView, attribute: .Height, relatedBy: .Equal, toItem: nil, attribute: .NotAnAttribute, multiplier: 1, constant: 80)
let friendRequestViewHeight = NSLayoutConstraint(item: friendRequestView, attribute: .Height, relatedBy: .Equal, toItem: nil, attribute: .NotAnAttribute, multiplier: 1, constant: 70)
NSLayoutConstraint.activateConstraints([friendRequestViewLeading, friendRequestViewTrailing, friendRequestViewTop, friendRequestViewHeight])
conversationCollectionView.contentInset.top += 80
conversationCollectionView.contentInset.top += 70
friendRequestView.user = conversation.withFriend
}
func tryRecoverMessageToolBar() {
@@ -10,6 +10,16 @@ import UIKit
class FriendRequestView: UIView {
var user: User? {
willSet {
if let user = newValue {
AvatarCache.sharedInstance.roundAvatarOfUser(user, withRadius: YepConfig.chatCellAvatarSize() * 0.5, completion: { [weak self] avatar in
self?.avatarImageView.image = avatar
})
}
}
}
lazy var avatarImageView: UIImageView = {
let imageView = UIImageView()
return imageView
@@ -34,7 +44,7 @@ class FriendRequestView: UIView {
lazy var actionButton: UIButton = {
let button = UIButton()
button.setTitle(NSLocalizedString("Add", comment: ""), forState: .Normal)
button.contentEdgeInsets = UIEdgeInsets(top: 10, left: 10, bottom: 10, right: 10)
button.contentEdgeInsets = UIEdgeInsets(top: 10, left: 15, bottom: 10, right: 15)
button.backgroundColor = UIColor.yepTintColor()
button.setTitleColor(UIColor.whiteColor(), forState: .Normal)
button.setTitleColor(UIColor.grayColor(), forState: .Highlighted)
@@ -45,11 +55,9 @@ class FriendRequestView: UIView {
override func didMoveToSuperview() {
super.didMoveToSuperview()
makeUI()
backgroundColor = UIColor.clearColor()
avatarImageView.backgroundColor = UIColor.redColor()
makeUI()
}
class ContainerView: UIView {