I can't exactly understand what have I done wrong. I tried removing the optional(?) but with no results.
Here's the total code of my Custom View :-
class CustomView: UIView {
var vieww: UIView!
override init(frame: CGRect) {
super.init(frame: frame)
setupView()
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
setupView()
}
func loadViewFromib () -> UIView {
let bundle = NSBundle(forClass: self.dynamicType)
let nib = UINib(nibName: NSStringFromClass(self.dynamicType).componentsSeparatedByString(".").last!, bundle: bundle)
let view = nib.instantiateWithOwner(self, options: nil).first as! UIView
return view
}
func setupView() {
vieww = loadViewFromib()
vieww.frame = CGRectMake(0, 0, 300, 150)
vieww.center = center
addSubview(vieww)
/// Adds a shadow to our view
vieww.layer.cornerRadius = 4.0
vieww.layer.shadowColor = UIColor.blackColor().CGColor
vieww.layer.shadowOpacity = 0.2
vieww.layer.shadowRadius = 4.0
vieww.layer.shadowOffset = CGSizeMake(0.0, 8.0)
}
I am new to swift and don't know what to do exactly. Please help me out.
Thanks in advance.