Can the value of the Identity Label be accessed in

2019-06-21 05:56发布

I have a number of labels in Interface builder which all have their identity label set (Identity inspector > Identity > Label.

I would now like to access these labels in my code. Is this generally possible or is this only present within Interface builder?

2条回答
【Aperson】
2楼-- · 2019-06-21 06:22

You can give different tags to your labels and then access labels by tags.

查看更多
何必那么认真
3楼-- · 2019-06-21 06:36

It would not be possible to access each labels Identity inspector > Identity > Label in your code. To better understand what the Identity label does, check out this link:

Label property in identity inspector

It would probably be better if you just accessed the label using the defined IBOulet. If you want to try something that is similar you could just set the tag property like so:

label.tag = 1;

Give each label a unique tag and you should be able to access it using

UILabel *label = [self.view viewWithTag:1];

查看更多
登录 后发表回答