Skip to content

Instantly share code, notes, and snippets.

@Athosone
Created January 3, 2016 17:44
Show Gist options
  • Save Athosone/6344b4f7be61fb63641c to your computer and use it in GitHub Desktop.
Save Athosone/6344b4f7be61fb63641c to your computer and use it in GitHub Desktop.
protocol EA_SessionViewsProtocol
{
static func instanceFromNib<T:EA_SessionViewsProtocol>() -> T
func displayDatasInView(datas:AnyObject?)
}
class EA_SessionViewsFactory {
static func CreateView<T:EA_SessionViewsProtocol>() -> T
{
return T.instanceFromNib()
}
}
static func instanceFromNib<T : EA_SessionViewsProtocol>() -> T {
let lRet = EA_DirectionView()
lRet.xibSetup()
lRet.updateLeftProgressBar(0.50)
lRet.updateRightProgressBar(0.10)
lRet.leftProgressBar.transform = CGAffineTransformMakeRotation(180.degreeToRadian);
return lRet as! T
}
func xibSetup() {
view = loadViewFromNib()
view.frame = bounds
//view.autoresizingMask = [UIViewAutoresizing.FlexibleWidth, UIViewAutoresizing.FlexibleHeight]
addSubview(view)
}
func loadViewFromNib() -> UIView {
let bundle = NSBundle(forClass: self.dynamicType)
let nib = UINib(nibName: "EA_DirectionView", bundle: bundle)
let view = nib.instantiateWithOwner(self, options: nil)[0] as! UIView
return view
}
//Displays the data pass as parameters in the views, need to cast it in the desired format e.g: PFObject
func displayDatasInView(datas: AnyObject?) {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment