Blog

Full width iOS Today Extension

18 Sep, 2014

Apple decided that the new Today Extensions of iOS 8 should not be the full width of the notification center. They state in their documentation:

Because space in the Today view is limited and the expected user experience is quick and focused, you shouldn’t create a widget that’s too big by default. On both platforms, a widget must fit within the width of the Today view, but it can increase in height to display more content.

Source: https://developer.apple.com/library/ios/documentation/General/Conceptual/ExtensibilityPG/NotificationCenter.html
This means that developers that create Today Extensions can only use a width of 273 points instead of the full 320 points (for iPhones pre iPhone 6) and have a left offset of the remaining 47 points. Though with the release of iOS 8, several apps like DropBox and Evernote do seem to have a Today Extension that uses the full width. This raises question wether or not Apple noticed this and why it came through the approval process. Does Apple not care?
Should you want to create a Today Extension with the full width yourself as well, here is how to do it (in Swift):
[objc]
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
if let superview = view.superview {
var frame = superview.frame
frame = CGRectMake(0, CGRectGetMinY(frame), CGRectGetWidth(frame) + CGRectGetMinX(frame), CGRectGetHeight(frame))
superview.frame = frame
}
}
[/objc]
This changes the super view (Today View) of your Today Extension view. It doesn’t use any private Api’s, but Apple might reject it for not following their rules. So think carefully before you use it.

guest
4 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Charles A.
Charles A.
7 years ago

You can adjust the default margin insets by implementing the NCWidgetProviding method widgetMarginInsetsForProposedMarginInsets(defaultMarginInsets: UIEdgeInsets) -> UIEdgeInsets. The default it passes has a 47 point left margin and a 39 point bottom margin. The following code would give you full control over the possible space:
[objc]
func widgetMarginInsetsForProposedMarginInsets(defaultMarginInsets: UIEdgeInsets) -> UIEdgeInsets {
return UIEdgeInsetsZero
}
[/objc]

chan
chan
7 years ago
Reply to  Charles A.

Great!!

hdkel
hdkel
7 years ago

THIS margin issue had been bothering me for a whole afternoon until I got the answer here . Nice blog and nice commenter. Thanks!

Explore related posts