So verwende ich PaintCode, um Formen zu machen, und ich möchte, dass meine UIButton
diese Form haben.UIButton und UIBezierPath
Die Form I sieht in Code wie folgt aus:
let bezierPath = UIBezierPath()
bezierPath.moveToPoint(CGPoint(x: 81.5, y: 48.5))
bezierPath.addLineToPoint(CGPoint(x: 105.5, y: 24.5))
bezierPath.addLineToPoint(CGPoint(x: 129.5, y: 48.5))
bezierPath.addLineToPoint(CGPoint(x: 123.5, y: 48.5))
bezierPath.addLineToPoint(CGPoint(x: 105.5, y: 30.5))
bezierPath.addLineToPoint(CGPoint(x: 87.5, y: 48.5))
bezierPath.addLineToPoint(CGPoint(x: 81.5, y: 48.5))
bezierPath.closePath()
UIColor.whiteColor().setFill()
bezierPath.fill()
UIColor.blackColor().setStroke()
bezierPath.lineWidth = 1
bezierPath.stroke()
Und Ich habe die UIButton
Schichten in meinem cellForItemAtIndexPath
, aber wie kann ich die Form, die ich auf meinem Knopf gemacht machen?
Also willst du im Grunde, dass diese Schaltfläche die richtige Form hat? –
@KrishWadhwana Ja, richtig. –
Haben Sie eine separate Klasse vom Typ UIButton erstellt und den Code dort eingegeben? Haben Sie die Funktion drawRect aufgerufen? –