开发者

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];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜