Skip to content

Instantly share code, notes, and snippets.

@sanketfirodiya
Created July 14, 2016 07:23
Show Gist options
  • Save sanketfirodiya/cb6361dbe3c66a75cd041520ff437af3 to your computer and use it in GitHub Desktop.
Save sanketfirodiya/cb6361dbe3c66a75cd041520ff437af3 to your computer and use it in GitHub Desktop.
NavBarImageTitleView
//
// 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)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment