I have witten a custom UIView class which takes several parameters and overrides an empty storyboard UIView(subclassed as MultiPositionTarget class instead of UIview) as below.The views below are linked as outlet to view controller as it is seen from the code below(in total 9 views).
// Initialize the targets
target1 = MultiPositionTarget(.zero,"targetTemp.png","David","Target")
target1.parentVC = self
targetList.append(target1)
However, it does not accept the parameters. And only loads the view. Here is my class below:
class MultiPositionTarget: UIView{
var targetName: String!
var bottomLabelName: String!
var imageName: String!
var isSelected: Bool!
var labelTop: UILabel!
var labelBottom: UILabel!
var parentVC: SelectTargetViewController!
init(_ frame: CGRect,_ imagName: String,_ targetname: String,_ targetlabel: String){
self.imageName = imagName
self.targetName = targetname
self.bottomLabelName = targetlabel
super.init(frame: frame)
setUp()
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
setUp()
}
func setUp(){
let viewWidth = self.bounds.width
let viewHeight = self.bounds.height
// Add top label
labelTop = UILabel(frame: CGRect(x: 0, y: 0, width: viewWidth, height: viewHeight/5))
//labelTop.center = CGPoint(x: 160, y: 285)
labelTop.textAlignment = .center
labelTop.font = UIFont(name:"System",size:6)
labelTop.text = self.imageName
labelTop.textColor = UIColor.white
labelTop.backgroundColor = hexStringToUIColor(hex: "#770B2C")
//labelTop.alpha = 0.5
self.addSubview(labelTop)
let image = UIImage(named: "targetTemp.png")
let imageView = UIImageView(image: image!)
imageView.frame = CGRect(x: 0, y: (viewHeight-viewHeight * 4/5), width: viewWidth, height: (viewHeight * 4/5))
self.addSubview(imageView)
// Add bottom Label
labelBottom = UILabel(frame: CGRect(x: 0, y: (viewHeight * 4/5), width: viewWidth, height: viewHeight/5))
//labelBottom.center = CGPoint(x: 160, y: 285)
labelBottom.textAlignment = .center
labelBottom.text = self.bottomLabelName
labelBottom.font = UIFont(name:"System",size:10)
labelBottom.textColor = UIColor.white
labelBottom.backgroundColor = hexStringToUIColor(hex: "770B2C")
labelBottom.alpha = 0.95
self.addSubview(labelBottom)
self.isUserInteractionEnabled = true
let viewTap = UITapGestureRecognizer(target: self, action: #selector(singleTap))
self.addGestureRecognizer(viewTap)
}
}
Any help or hint is appreciated. Thanks in advance stack overflow family.

// Initialize the targets? Istarget1the outlet? Why are you initialising an outlet?