ios - Incomplete UIBezierPath Stroke -


i'm creating split button on ios using 2 uibuttons placed next each other. so:

enter image description here

as can see, there's small bite taken out of right button's top left corner undesirable. i'd part of stroke complete.

the right button uses uibezierpath sublayer draw border around button:

let borderwidth = cgfloat(4.0) let borderlayer = cashapelayer()  var borderframe = button.bounds.insetby(dx: borderwidth/2.0, dy: borderwidth/2.0)  borderlayer.frame = borderframe borderframe.origin = cgpoint.zero  borderlayer.path = uibezierpath(roundedrect: borderframe, byroundingcorners: [.topright, .bottomright], cornerradii: radius).cgpath  borderlayer.linewidth = borderwidth borderlayer.fillcolor = uicolor.white.cgcolor borderlayer.strokecolor = uicolor.green.cgcolor  button.layer.addsublayer(borderlayer) 

if use

borderlayer.path = cgpath(rect: borderframe, transform: nil) 

instead of uibezierpath, works fine. , if round top left corner of uibezierpath works fine.

can me figure out how draw border way i'd to? in advance!

although uibezierpath(roundedrect:byroundingcorners:cornerradii:) documented return closed subpath, doesn't, in testing:

import uikit  let path = uibezierpath(roundedrect: cgrect(x: 0, y: 0, width: 40, height: 40), byroundingcorners: [.topright, .bottomright], cornerradii: cgsize(width: 10, height: 10)) print(path) 

output:

<uibezierpath: 0x6180000a5d00; <moveto {0, 0}>,  <lineto {24.713349999999998, 0}>,  <curveto {33.300654247944713, 0.65495893024402596} {29.115070423814711, 0} {31.315930559369978, 0}>,  <lineto {33.685062071690076, 0.74911387847016009}>,  <curveto {39.250886121529845, 6.3149379283099272} {36.27176173374253, 1.6905955604436995} {38.30940443955631, 3.7282382662574722}>,  <curveto {40, 15.286649847295823} {40, 8.6840694406300223} {40, 10.884929576185289}>,  <lineto {40, 24.713349999999998}>,  <curveto {39.345041069755972, 33.300654247944713} {40, 29.115070423814711} {40, 31.315930559369978}>,  <lineto {39.250886121529845, 33.685062071690076}>,  <curveto {33.685062071690076, 39.250886121529838} {38.30940443955631, 36.27176173374253} {36.27176173374253, 38.309404439556296}>,  <curveto {24.713350152704177, 40} {31.315930559369978, 40} {29.115070423814711, 40}>,  <lineto {0, 40}>,  <lineto {0, 0}>,  <lineto {0, 0}> 

it has line last corner first, not same closed path. there's no joint @ first corner, draws overlapping line caps instead of single joint.

try this:

let path = uibezierpath(roundedrect: borderframe, byroundingcorners: [.topright, .bottomright], cornerradii: radius) path.close() borderlayer.path = path.cgpath 

Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -