|
// |
|
// NavigationBarProfileImage.swift |
|
// Tuity-iOS |
|
// |
|
// Created by Sanket Firodiya on 5/30/16. |
|
// Copyright © 2016 Tuity. All rights reserved. |
|
// |
|
|
|
import UIKit |
|
|
|
class NavBarImageTitleView: UIView { |
|
private var titleLabel = UILabel() |
|
private var imageView = UIImageView() |
|
|
|
convenience init(frame: CGRect, imageUrl: String?, title: String?) { |
|
self.init(frame: frame) |
|
if imageUrl != nil { |
|
ImageProvider.sharedInstance.fetchImageWithUrl(imageUrl, completionBlock: { (image) in |
|
self.imageView.image = image |
|
}) |
|
} |
|
if title != nil { |
|
self.titleLabel.text = title |
|
} |
|
} |
|
|
|
override init(frame: CGRect) { |
|
super.init(frame: frame) |
|
} |
|
|
|
required init?(coder aDecoder: NSCoder) { |
|
fatalError("init(coder:) has not been implemented") |
|
} |
|
|
|
override func drawRect(rect: CGRect) { |
|
self.imageView.frame = CGRectMake(0.0, 6.0, 32.0, 32.0) |
|
self.imageView.layer.cornerRadius = 16.0 |
|
self.imageView.layer.borderWidth = 0.5 |
|
self.imageView.layer.borderColor = UIColor.clearColor().CGColor |
|
self.imageView.clipsToBounds = true |
|
self.titleLabel.frame = CGRectMake(43.0, 11.0, self.frame.size.width - 40.0, 20.0) |
|
self.titleLabel.numberOfLines = 1 |
|
self.titleLabel.font = UIFont.tuityFontWithSize(18.0) |
|
self.titleLabel.textColor = UIColor.blackColor() |
|
self.addSubview(self.imageView) |
|
self.addSubview(self.titleLabel) |
|
} |
|
} |