自定义ios UIAlertView, 重排按钮位置

来源:互联网 发布:天罡掌诀推算法 编辑:程序博客网 时间:2024/05/01 05:03

参考:http://www.cnblogs.com/xiaodao/archive/2012/07/12/2588582.html


首选,实现UIAlertView的Delegate ,UIAlertViewDelegate。

实现:

- (void)willPresentAlertView:(UIAlertView *)alertView

在这个方法里修攺布局简洁,方便,需要在这个方法中找到需要修攺的视图的tag

通过viewWithTag,得到view,再重设其frame,即可重布局需要修攺的视图


查找需要修攺的view的tag:

for (UIView * temp in [alertView subviews]) {

        NSLog(@"The Alert Subview Object:%@", temp);

    }

注意:在打印出来的log,按钮是这样UIThreePartButton,通过一般的 [[temp class] isSubclassOfClass:[UIButton class]],无法得到button




Demo URL: http://download.csdn.net/detail/take8619702/4698646