safearealayoutguide

Get safe area inset top and bottom heights

橙三吉。 提交于 2019-11-26 17:34:40
问题 On the new iPhone X, what would be the most proper way to get both top and bottom height for the unsafe areas? 回答1: Try this : In Objective C if (@available(iOS 11.0, *)) { UIWindow *window = UIApplication.sharedApplication.keyWindow; CGFloat topPadding = window.safeAreaInsets.top; CGFloat bottomPadding = window.safeAreaInsets.bottom; } In Swift if #available(iOS 11.0, *) { let window = UIApplication.shared.keyWindow let topPadding = window?.safeAreaInsets.top let bottomPadding = window?

Use Safe Area Layout programmatically

我们两清 提交于 2019-11-26 15:02:19
Since I don't use storyboards to create my views, I was wondering if there's the "Use Safe Area Guides" option programmatically or something like that. I've tried to anchor my views to view.safeAreaLayoutGuide but they keep overlapping the top notch in the iPhone X simulator. Krunal Here is sample code (Ref from: Safe Area Layout Guide ): If you create your constraints in code use the safeAreaLayoutGuide property of UIView to get the relevant layout anchors. Let’s recreate the above Interface Builder example in code to see how it looks: Assuming we have the green view as a property in our view

iOS 11 safe area layout guide backwards compatibility

天大地大妈咪最大 提交于 2019-11-26 11:54:21
问题 Is enabling Safe Area Layout Guides compatible to iOS below 11? 回答1: I managed to work with the new Safe Area layout guides and maintain backwards compatibility with iOS 9 and iOS 10: (EDIT: as pointed out in the comments by @NickEntin, this implementation will presume there is a status bar present, which won't be true in landscape on the iPhone X. Resulting in to much space to the top (20 points). It will run perfectly fine however. E.g. if you want a view to be 10 points below the status

Use Safe Area Layout programmatically

梦想的初衷 提交于 2019-11-26 04:36:33
问题 Since I don\'t use storyboards to create my views, I was wondering if there\'s the \"Use Safe Area Guides\" option programmatically or something like that. I\'ve tried to anchor my views to view.safeAreaLayoutGuide but they keep overlapping the top notch in the iPhone X simulator. 回答1: Here is sample code (Ref from: Safe Area Layout Guide): If you create your constraints in code use the safeAreaLayoutGuide property of UIView to get the relevant layout anchors. Let’s recreate the above

Safe Area of Xcode 9

社会主义新天地 提交于 2019-11-26 00:17:35
问题 While exploring Xcode9 Beta Found Safe Area on Interface builders View hierarchy viewer. Got curious and tried to know about Safe Area on Apples documentation, in gist the doc says \"The the view area which directly interacts with Auto layout\" But it did not satisfy me, I want to know Practical use of this new thing. Do any one have some clue? Conclusion paragraph from Apple doc for Safe area. The UILayoutGuide class is designed to perform all the tasks previously performed by dummy views,