How to make the close icon (red x) on the view?
I want to do the same as mobile safari multi-page mode, a red x on the top right s开发者_JAVA百科creenshot of previously opened page, tap it to close it.
I searched but couldn't find any. Is it a out-of-box widget in iOS or something I should custom make it?
Create an image that is the same as the close icon (there isn't a way through public APIs to get it) and set it as the background of a UIButton. Then, add it as a subview of your page. Done.
UIButton* closeButton = [[UIButton alloc]
initWithFrame:CGRectMake(0.0f, 0.0f, 25.0f, 25.0f)];
[closeButton addTarget:self
action:@selector(didTapCloseButton:)
forControlEvents:UIControlEventTouchUpInside];
[closeButton setBackgroundImage:[UIImage imageNamed:@"closeButton.png"]
forState:UIControlStateNormal];
[self.pageView addSubview:button];
[closeButton release];
精彩评论