【发布时间】:2015-10-31 18:28:12
【问题描述】:
我创建了一个自定义窗口
let alertWindow = UIWindow(frame: UIScreen.mainScreen().bounds)
let background = UIToolbar(frame: alertWindow.frame)
background.barStyle = .Black
background.translucent = true
alertWindow.addSubview(background)
alertWindow.makeKeyAndVisible()
仅当我将 UIWindow 变量作为全局变量放入 AppDelegate 时才会出现。
我看到很多 Pod 使用自定义 UIWindow 作为通知横幅或自定义 AlertView。但他们没有将自定义 UIWindow 放在 AppDelegate 中,而是放在自定义类中。
例如:
这是来自 CRToast 的代码
https://github.com/cruffenach/CRToast
@interface CRToastManager () <UICollisionBehaviorDelegate>
@property (nonatomic, readonly) BOOL showingNotification;
@property (nonatomic, strong) UIWindow *notificationWindow;
@property (nonatomic, strong) UIView *statusBarView;
@property (nonatomic, strong) UIView *notificationView;
他将自定义窗口放在 CRToastManager 类中,而不是应用程序委托中,在我的情况下,当我将它放在自定义类中时,它不会出现。它需要在应用委托中是可变的。
如何显示自定义窗口并将其放入自定义类中?
【问题讨论】:
标签: ios objective-c swift uikit uiwindow