Capa UILabel.cornerRadius no funciona en iOS 7.1


Actualmente estoy viendo un UILabel con la propiedad addMessageLabel.layer.cornerRadius = 5.0f; En un dispositivo con iOS 7.0 instalado, tiene esquinas redondeadas. En un dispositivo con iOS 7.1 instalado, no tiene esquinas redondeadas.

¿Es esto solo un error con iOS 7.1?

Author: Honey, 2014-03-11

7 answers

Establezca la propiedad clipsToBounds en true

addMessageLabel.clipsToBounds = true
 438
Author: Raheel Sadiq,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-01-01 05:59:05

Creo que la mejor manera de establecer el radio de esquina es:

introduzca la descripción de la imagen aquí

Y asegúrese de que el" Clip Subviews " está marcado:

introduzca la descripción de la imagen aquí

Marcar "Subviews de clip" es igual al código addMessageLabel.clipsToBounds = YES;.

 60
Author: Allen,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-04-03 18:59:33

Agregue la siguiente línea dos y compruébela.

[[addMessageLabel layer] setCornerRadius:5.0f];
[[addMessageLabel layer] setMasksToBounds:YES];

O

[addMessageLabel setClipsToBounds:YES];
 22
Author: Tapas Pal,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-04-17 05:14:02

He probado el siguiente y obtuve una salida exitosa.

yourlabelname.layer.cornerRadius = 10.0f;
[yourlabelname setClipsToBounds:YES];

¿Hay algo más que te está deteniendo?

 3
Author: Mano Rajendran,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-05-13 14:50:55

Mi problema era un poco diferente.

Mientras que yo hice hice btn.clipsToBounds = true

No estaba configurando hacer:

btn.layer.cornerRadius = 20

Porque tenía diferentes tamaños de pantalla. En cambio, seguí esta respuesta y lo hice:

override func layoutSubviews() {
    seeMoreButton.layer.cornerRadius = seeMoreButton.bounds.size.height / 2
}

No funcionaba porque olvidé agregar super.layoutSubviews(). El código correcto es:

override func layoutSubviews() {
    super.layoutSubviews()
    seeMoreButton.layer.cornerRadius = seeMoreButton.bounds.size.height / 2
}
 3
Author: Honey,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-10-25 18:23:30
 //works perfect in Swift 2.0 for a circular or round image          


@IBOutlet var theImage: UIImageView!
        override func viewDidLoad() {
            super.viewDidLoad()
    //Make sure the width and height are same
            self.theImage.layer.cornerRadius = self.theImage.frame.size.width / 2
            self.theImage.layer.borderWidth = 2.0
            self.theImage.layer.borderColor = UIColor.whiteColor().CGColor
            self.theImage.clipsToBounds = true

        }
 0
Author: Naishta,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-04-16 22:02:50
yourlabelname.layer.cornerRadius = yourlabelname.frame.size.width/2;
[yourlabelname setClipsToBounds:YES];

Asegúrese de que está verificando con el destino de implementación apropiado.

 0
Author: iAmita Singh,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-06-29 11:17:05