A simple solution to set a placeholder or show UIView's size. It's a Swift version of MMPlaceHolder, which written in objc (Now MMPlaceHolder
has its own official Swfit version XXPlaceHolder).
Please see the original MMPlaceHolder for more introduction.
XYViewPlaceholder
implemented by using method swizzling (中文翻译见这里).
Just drag XYViewPlaceholder.swift
file to your Swfit project.
Simply write one line code.
yourView.showPlaceholder()
or customize yourself.
// show
showPlaceholderWith(lineColor: UIColor)
showPlaceholderWith(lineColor: UIColor, backColor: UIColor)
showPlaceholderWith(lineColor: UIColor, backColor: UIColor, arrowSize: CGFloat)
showPlaceholderWith(lineColor: UIColor, backColor: UIColor, arrowSize: CGFloat, lineWidth: CGFloat)
showPlaceholderWith(lineColor: UIColor, backColor: UIColor, arrowSize: CGFloat, lineWidth: CGFloat, frameWidth: CGFloat, frameColor: UIColor)
// show all sub views
yourView.showPlaceholderWithAllSubviews()
yourView.showPlaceHolderWithAllSubviewsWith(maxPath: UInt)
// hide
yourView.hidePlaceholder()
yourView.hidePlaceholderWithAllSubviews()
// remove
yourView.removePlaceholder()
yourView.removePlaceholderWithAllSubviews()
Fix hide and remove placeholders.(Thanks @adad184 for telling me this bug)
This code is distributed under the terms and conditions of the MIT license.