Noha Mohamed Noha Mohamed - 8 months ago 40
Objective-C Question

How do I change the height of an iOS extension?

How do I change the height of an iOS 10 extension in compact mode? Or more broadly, how do I change the height of an extension without using



I'm using like this, maybe this will help your problem :

override func viewDidLoad() {

        self.preferredContentSize = CGSize(width:self.view.frame.size.width, height:210)

        if #available(iOSApplicationExtension 10.0, *) {
            self.extensionContext?.widgetLargestAvailableDisplayMode = .expanded

height as 210 how I prefer, you can use any height of course...


If you want to use a fixed size you can use NCWidgetDisplayMode's second option "compact":

@available(iOS 10.0, *)
public enum NCWidgetDisplayMode : Int {

    case compact // Fixed height

    case expanded // Variable height

you can update your code like below :

if #available(iOSApplicationExtension 10.0, *) {
    self.extensionContext?.widgetLargestAvailableDisplayMode = .compact