Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hide a subview with a tag

Tags:

ios

swift

In swift I can give a view a tag

  let MY_CUSTOM_TAG = 123
  tableView.tag = MY_CUSTOM_TAG

My question is, how do I remove a view from the superview with a tag using swift?

Objective C example:

#define MY_CUSTOM_TAG 1234
mySubview.tag = MY_CUSTOM_TAG;
[self.tableView addSubview:mySubview] ;

//remove view with tag

[[self.tableView viewWithTag:MY_CUSTOM_TAG]removeFromSuperview] ;
like image 897
The Regulator Avatar asked Jul 11 '14 19:07

The Regulator


1 Answers

It's the same way with Objective-C, just has a different syntax;

view.viewWithTag(tag).removeFromSuperview()
like image 65
ujell Avatar answered Sep 25 '22 00:09

ujell