How to Insert View in Superview's View? (iOS)

前端 未结 4 1714
时光取名叫无心
时光取名叫无心 2021-01-22 17:16

I have the line of code below... How would I modify it to insert the subview in the superview\'s view named \'foo\'?

[[self superview] addSubview:copy3];
         


        
4条回答
  •  花落未央
    2021-01-22 17:53

    First tag the view myView with a unique number:

    myView.tag = 0x1234;
    

    Then you can find it using viewWithTag:

    [[[self superview] viewWithTag:0x1234] addSubview:mySubview];
    

提交回复
热议问题