首页 > 其他 > 详细

mono touch中,给顶层容器添加遮罩

时间:2014-01-21 09:56:11      阅读:463      评论:0      收藏:0      [点我收藏+]

LoadingOverlay loadingOverlay = new LoadingOverlay (UIScreen.MainScreen.Bounds);


方法一、针对视图或视图控制器的单体对象操作:

UIApplication.SharedApplication.Windows.Last ().AddSubview (loadingOverlay);方法


方法二、针对父容器操作:

tabBarController.ViewControllerSelected+= delegate(object sender1, UITabBarSelectionEventArgs e) {......}

ViewControllerSelected事件中添加遮罩:

this.NavigationController.View.AddSubview (loadingOverlay);


移除,异步线程中处理。

针对一的移除,直接处理就行:

if (loadingOverlay != null) {
    loadingOverlay.Hide ();
    loadingOverlay.Dispose ();
}

================分割线=================

针对二的移除,需要遍历父级容器找到目标然后移除:

var qv = from t in this.NavigationController.View.Subviews
         where t is LoadingOverlay
         select t;
if (qv.Count () > 0)
    ((UIView)qv.First ()).RemoveFromSuperview ();


推荐使用第一种方法,另外可以研究下UIApplication.SharedApplication对象,应该是个单例对象


PS:LoadingOverlay的源码参考:http://blog.csdn.net/joyhen/article/details/17222117

mono touch中,给顶层容器添加遮罩

原文:http://blog.csdn.net/joyhen/article/details/18226907

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!