tags:

views:

71

answers:

1

I want to create a UIView programmatically, and want a close "X" button at the top left vertice of the View. When i press the close button view disappears. Is it possible??

+2  A: 

Make a button with frame CGRect (0, 0, 20, 20), then add it to the view. [UIView addSubView] set the target of the button.

UIButton *closeButton = [UIButton initWithRect: CGRectMake(0,0,20,20)];
[closeButton addTarget:self action:@selector(closeView) forControlEvents:UIControlEventTouchUpInside];
karim