Melvin Lai
Melvin Lai

Reputation: 901

Is there a method to clear UILabel and UIImageView?

Is there another way to clear a UILabel text and a UIImageView image without doing something like this?

label.text = @"";
image setImage:[UIImage imageNamed:@""];

Are there methods to execute these actions?

Upvotes: 2

Views: 1599

Answers (3)

luisdemarchi
luisdemarchi

Reputation: 1572

The problem is old and already has a solution marked! but for Swift 3 I got it like this:

    self.label.text = "00:00:01"
    self.label.setNeedsLayout()
    self.label.text = "00:00:02"
    self.label.setNeedsLayout()
    self.label.text = "00:00:03"
    self.label.setNeedsLayout()

Upvotes: 0

user2682269
user2682269

Reputation: 11

I had a similar problem (used to put label.text =@"";). This worked for me: label.text =nil;

Upvotes: 1

Ankit Srivastava
Ankit Srivastava

Reputation: 12405

these also work if you just want to play around..

label.text =nil;
    image.image= nil;

what exactly do you wish to achieve....?

Upvotes: 1

Related Questions