Noha Mohamed Noha Mohamed - 1 year ago 69
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


Answer Source

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
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download