ios - Add handles around UIImageView -
so have few uiimageview's can "spawn" on screen, , scale,rotate, , move using gesture recognizer. want add 2 things, simple line around uiimageview let user know view selected. , button around line if tapped delete view. i've tried https://www.cocoacontrols.com/controls/spuserresizableview , couldn't implement right way in swift.
i recommend creating simple uiview subclass contain uiimageview , uibutton (i don't quite understand want button positioned can setup constraints based on needs). subclass wrap whole functionality of 1 spawned imageview.
then:
creating delete action when uibutton tapped pretty straight forward.
creating selection effect done several approaches:
you create uiview (with backgroundcolor equal selectedstatecolor) behind uiimageview (slightly bigger uiimageview) simulate select action
you use uiimageview layer , play bordercolor / borderwidth this:
func handletap(gesturerecognizer: uigesturerecognizer) { // if >0 selected let borderwidth : cgfloat = imageview.layer.borderwidth > 0.0 ? 0.0 : 4.0 // set border width imageview.layer.bordercolor = uicolor.greencolor().cgcolor imageview.layer.borderwidth = borderwidth }
and option play cashapelayer (where you'd specify cgmutablepathref path of shapelayer) -> lots of options there - linewidth, stroke color, fillcolor, line patterns, ... etc
if simple line around uiimageview need recommend using layers because it's quite easy setup (just few lines of code).
hope helps :). please let me know if need more information (please more descriptive).
cheers!
Comments
Post a Comment