Change UIPopoverView background + arrow color

后端 未结 5 1447
猫巷女王i
猫巷女王i 2021-01-03 18:19

Is there a way to simply change the UIPopoverView background color (including its arrow) on iOS8?

(I did read a couple of articles on customizing \"UIPopove

5条回答
  •  孤独总比滥情好
    2021-01-03 19:06

    You can simply modify popover like this:

        let popoverViewController = self.storyboard?.instantiateViewControllerWithIdentifier("popoverSegue")
        popoverViewController!.popoverPresentationController?.delegate = self
        popoverViewController!.modalPresentationStyle = .Popover
    
    
        let popoverSize = CGSize(width: 150, height: 60)
        popoverViewController!.preferredContentSize = popoverSize
        let popover = popoverViewController!.popoverPresentationController
        popover?.delegate = self
        popover?.permittedArrowDirections = .Up
        popover?.sourceView = self.view
    
        //change background color with arrow too!
        popover?.backgroundColor = UIColor.whiteColor()
        popover?.sourceRect = CGRect(x: self.view.frame.width, y: -10, width: 0, height: 0)
        presentViewController(popoverViewController!, animated: true, completion: nil)
    

提交回复
热议问题