Créer un coin de bouton rectangle arrondi personnalisé en haut à gauche?

J'ai un bouton personnalisé que je veux faire en haut à gauche de la frontière de ressembler à la normale de rectangle arrondi.

J'ai trouvé un code qui permet tous les coins ronds:

_myButton.layer.cornerRadius = 8;
_myButton.layer.borderWidth = 0.5;
_myButton.layer.borderColor = [UIColor grayColor].CGColor;
_myButton.clipsToBounds = YES;

Créer un coin de bouton rectangle arrondi personnalisé en haut à gauche?

Comment puis-je corriger le code pour le rendre rond juste en haut à gauche?


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];

Ce code ne fonctionne pas. Le bouton disparaît.

source d'informationauteur Ali