Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Matheus193dn/80a90f288578780c3cb6e06431dc21ce to your computer and use it in GitHub Desktop.
Save Matheus193dn/80a90f288578780c3cb6e06431dc21ce to your computer and use it in GitHub Desktop.

Revisions

  1. @bishalg bishalg created this gist May 18, 2016.
    23 changes: 23 additions & 0 deletions CircularImageView.swift
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    // Created by Bishal Ghimire on 5/15/16.

    import UIKit

    @IBDesignable
    class CircularImageView: UIImageView {

    override func prepareForInterfaceBuilder() {
    super.prepareForInterfaceBuilder()
    makeCircularImage()
    }

    // drawRect will not work on UIImageView
    override func layoutSubviews() {
    super.layoutSubviews()
    makeCircularImage()
    }

    func makeCircularImage() {
    self.layer.cornerRadius = self.frame.size.height / 2
    }

    }