uitraitcollection

UIPresentationController changes size when another view controller is displayed on top of it

白昼怎懂夜的黑 提交于 2019-11-29 14:48:43
问题 I am presenting a modal view controller using UIPresentationController. I am setting the frame of presentedView less than the containView's bounds using following method: override func frameOfPresentedViewInContainerView() -> CGRect { let myDX = (self.containerView!.bounds.width - 600)/2 let myDY = (self.containerView!.bounds.height - 600)/2 return self.containerView!.bounds.insetBy(dx: myDX, dy: myDY) } Everything works great unto this point. Now, I present another view controller modally

How to detect Light\Dark mode change in iOS 13?

流过昼夜 提交于 2019-11-28 08:58:27
问题 Some of the UI setups not working automatically with the Dark/Light mode change as the UIColor . For example shadow in layer. As I need to remove and drop shadow in dark and light mode, I need somewhere to put updateShadowIfNeeded() function. I know how to detect what is the mode currently: func dropShadowIfNeeded() { switch traitCollection.userInterfaceStyle { case .dark: removeShadow() case .light: dropShadowIfNotDroppedYet() default: assertionFailure("Unknown userInterfaceStyle") } } Now I