IBOutlet properties nil after custom view loaded from xib

That’s expected, because the IBOutlet(s) are not assigned by the time the initializer is called. Instead of calling commonInit() in init(coder:), do that in an override of awakeFromNib as follows: // … required init(coder aDecoder: NSCoder) { super.init(coder: aDecoder) } override func awakeFromNib() { super.awakeFromNib() commonInit() } // …

How do I create a UIView with a transparent circle inside (in swift)?

Updated again for Swift 4 & removed a few items to make the code tighter. Please note that maskLayer.fillRule is set differently between Swift 4 and Swift 4.2. func createOverlay(frame: CGRect, xOffset: CGFloat, yOffset: CGFloat, radius: CGFloat) -> UIView { // Step 1 let overlayView = UIView(frame: frame) overlayView.backgroundColor = UIColor.black.withAlphaComponent(0.6) // Step 2 let … Read more

UIView with a Dashed line

Check UIBezierPath setLineDash:count:phase: method: – (void)setLineDash:(const CGFloat *)pattern count:(NSInteger)count phase:(CGFloat)phase` method. This allows you to draw dashed lines. First add a CAShapeLayer. Add it as sublayer to your UIView. It has a path property. Now make an object of UIBezierPath. Draw the line using setLineDash. For example: UIBezierPath *path = [UIBezierPath bezierPath]; //draw a line … Read more

How do I make an expand/contract transition between views on iOS?

Making the effect is simple. You take the full-sized view, initialize its transform and center to position it on top of the thumbnail, add it to the appropriate superview, and then in an animation block reset the transform and center to position it in the final position. To dismiss the view, just do the opposite: … Read more

xcode/iOS: Autoresize to fill a view – explicit frame size is essential?

Autoresizing does not mean that the subview will take up the size of its superview. It just means that it will resize relative to the size change of its superview whenever the superview’s bounds change. So initially, you have to set the size of the subview to the correct value. The autoresizing mask will then … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)