Ho un pulsante personalizzato che voglio che il bordo in alto a sinistra assomigli al normale rettangolo rotondo.Crea un angolo personalizzato con un rettangolo arrotondato in alto a sinistra?
ho trovato il codice che rende tutti gli angoli arrotondati:
_myButton.layer.cornerRadius = 8;
_myButton.layer.borderWidth = 0.5;
_myButton.layer.borderColor = [UIColor grayColor].CGColor;
_myButton.clipsToBounds = YES;
Come posso correggere il codice per renderlo turno solo nella parte in alto a sinistra?
Edit:
_myButton.layer.borderWidth = 2;
_myButton.layer.borderColor = [UIColor blackColor].CGColor;
UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:_myButton.bounds
byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight
cornerRadii:CGSizeMake(7.0, 7.0)];
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
maskLayer.frame = _myButton.bounds;
maskLayer.path = maskPath.CGPath;
_myButton.layer.mask = maskLayer;
[maskLayer release];
Questo codice non funziona. L'intero pulsante scompare.
Ecco una simile domanda/risposta su come è possibile utilizzare un UIBezierPath per dire che gli angoli per mantenere/maschera su un UIView: http://stackoverflow.com/questions/10995226/how-to -make-a-half-rounded-top-corner-rounded-texview-with-border – Brayden
Ho usato il codice fornito lì. ma non funziona. Ho aggiunto il codice alla fine della domanda. puoi aiutarmi @Brayden? – Ali