Personalice las esquinas redondeadas de las cuatro esquinas de la Vista y la configuración del borde

Utilice curvas de Bézier

typedef NS_OPTIONS(NSUInteger, UIRectCorner) {

    UIRectCornerTopLeft = 1 << 0,

    UIRectCornerTopRight = 1 << 1,

    UIRectCornerBottomLeft = 1 << 2,

    UIRectCornerBottomRight = 1 << 3,

    UIRectCornerAllCorners = ~0UL

};

//16 colores

#define RGB16Color(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 verde:((float)((rgbValue & 0xFF00) >> 8))/255.0 azul:(( flotante)(rgbValue y 0xFF))/255.0 alfa:1.0]

 

UIButton * elijaButton = [UIButton buttonWithType:UIButtonTypeCustom];

elegirBotón.frame = CGRectMake(10, 15, 86, 24);

[self.view addSubview:elegirBotón];

UIBezierPath *maskPath_two = [UIBezierPath bezierPathWithRoundedRect: elijaButton.bounds byRoundingCorners:UIRectCornerTopRight | UIRectCornerBottomEsquina derechaRadios:CGSizeMake(5,5)];

    //Crear capa

    CAShapeLayer *maskLayer_two = [[CAShapeLayer alloc] init];

    maskLayer_two.frame = elegirBotón.bounds;

    //asignación

    MaskLayer_two.path = MaskPath_two.CGPath;

    elegirBotón.capa.mask = maskLayer_two;

Establezca el borde en base a lo anterior.

//establecer borde

    CAShapeLayer *borderLayer = [capa CAShapeLayer];

    borderLayer.frame = elegirButton.bounds;

    borderLayer.path = maskPath_two.CGPath;

    borderLayer.lineWidth = 1;

    borderLayer.fillColor = [UIColor clearColor].CGColor;

    borderLayer.strokeColor = RGB16Color(0x30C26D).CGColor;

    [elegirBotón.capa agregarSubcapa:borderLayer];

 

Supongo que te gusta

Origin blog.csdn.net/KLong27/article/details/103896688
Recomendado
Clasificación