ioscontrol-center

Is it possible to display the control center in button click? ios


I'm having a problem in displaying the control center in iOS, i've been searching for some docs regarding on this issue but couldn't find an answer. Is there a way, to make the control center appear by clicking a UIButton?.


Solution

  • You can apply constraints programatically to a specific UI element (link to iOS developer doc)

    Sample code of this eg.:

    // Center horizontally
    [self.view addConstraint:[NSLayoutConstraint constraintWithItem:viewToBeCentered
                                                          attribute:NSLayoutAttributeCenterX
                                                          relatedBy:NSLayoutRelationEqual
                                                             toItem:self.view
                                                          attribute:NSLayoutAttributeCenterX
                                                         multiplier:1.0
                                                           constant:0.0]];
    
    // Center vertically
    [self.view addConstraint:[NSLayoutConstraint constraintWithItem:viewToBeCentered
                                                          attribute:NSLayoutAttributeCenterY
                                                          relatedBy:NSLayoutRelationEqual
                                                             toItem:self.view
                                                          attribute:NSLayoutAttributeCenterY
                                                         multiplier:1.0
                                                           constant:0.0]];
    

    You can include this code into your button's action code.

    Hope this helps to achieve the desired effect!