Skip to content

Custom UIView that creates holes into the view

License

Notifications You must be signed in to change notification settings

hlts2/UIHoleView

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

UIHoleView

UIHoleView is the custom UIView that creates holes.

Installation

  1. Add this line to your Cartfile: github "hlts2/UIHoleView"
  2. Read the official instruction

Usage

  1. imports the UIHoleView package
import UIHoleView
  1. creates hole and custom view
// defines hole type. this example code is square hole.
let hole = Hole(path: UIBezierPath(rect: CGRect(x: 0, y: 0, width: 200, height: 200)),
                color: UIColor.clear,
                drawer: DrawSquareHole())

let holeView = UIHoleView(frame: self.view.bounds) // or let holeView = UIHoleView(holes: [hole])

// sets holes
holeView.setHoles([hole])

// sets background color outside holes
holeView.backgroundColor = UIColor.black.withAlphaComponent(0.5)

// adds holeview into self.view
self.view.addSubview(self.holeView)

Hole type

  • Square Hole
let hole = Hole(path: UIBezierPath(rect: CGRect(x: 0, y: 0, width: 200, height: 200)),
                color: UIColor.clear,
                drawer: DrawSquareHole())

  • Circule Hole
let hole = Hole(path: UIBezierPath(rect: CGRect(x: 0, y: 0, width: 200, height: 200)),
                color: UIColor.clear,
                drawer: DrawCircleHole())

  • Rounded Corner Hole
let hole = Hole(path: UIBezierPath(roundedRect: CGRect(x: 0, y: 0, width: 200, height: 200), cornerRadius: 10),
                color: UIColor.clear,
                drawer: DrawRoundedCornerHole())

License

UIHoleView is released under the MIT license. Go read the LICENSE file for more information.