How to get a certain subview from UIView by tag

前端 未结 6 1113
野趣味
野趣味 2021-02-03 21:00

I\'m a noob in Objective-C and I have one question.

I have one UILabel object that I adding to one UIView with this code:

UILabel *label = [         


        
6条回答
  •  终归单人心
    2021-02-03 21:53

    If you are on the same view

    UILabel *tagLabel =  (UILabel*)[view viewWithTag:1];
    

    Also, if you want a new instance of UILabel

    UILabel *newTagLabel = [tagLabel copy];
    //customize new label here...
    [view addSubView:newTagLabel];
    

提交回复
热议问题