如何为viewcontroller添加自定义边框(ios)

时间:2016-05-28 19:13:02

标签: ios swift

我有一个视图(UIPopoverPresentation)哪个功能正常,但我需要添加一个自定义边框。我目前正在使用borderWidth和borderColor,但我似乎无法找到制作自定义边框的方法,如下图所示。如何创建此自定义边框?制作CGRect?


我需要什么:

enter image description here


我拥有的: enter image description here

我试图将图像添加到弹出框的背景中,结果是:
enter image description here

编辑:// PopOverView(使用UIPopOverPresentation呈现)

    override func viewDidLoad() {
    super.viewDidLoad()

    self.view.layer.cornerRadius = 10.0
    self.view.layer.borderWidth = 1.5
    self.view.layer.borderColor = UIColor.whiteColor().CGColor
    self.navigationController?.navigationBarHidden = true
    self.popViewTableView.delegate = self
    self.popViewTableView.dataSource = self
    self.popViewTableView.alwaysBounceVertical = false
    self.popViewTableView.backgroundColor =  UIColor(red: 151.0/255.0, green: 87.0/255.0, blue: 172.0/255.0, alpha: 1.0)


}


//Base View Controller.  When button is pressed, this function is called which presents the popover
func presentPopOver() {

    let contentView = UIStoryboard(name: "Main", bundle: nil).instantiateViewControllerWithIdentifier("popViewController") as! DeckPopViewController
    contentView.modalPresentationStyle = UIModalPresentationStyle.Popover
    contentView.preferredContentSize = CGSizeMake(deckSelectionCGRect.width, 160)

    let popoverMenuViewController = contentView.popoverPresentationController!
    popoverMenuViewController.delegate = self
    popoverMenuViewController.sourceView = view
    popoverMenuViewController.permittedArrowDirections = UIPopoverArrowDirection(rawValue:0)

    popoverMenuViewController.sourceRect = CGRectMake((self.view.bounds.width/2) - (deckSelectionCGRect.width/2), 120, deckSelectionCGRect.width, deckSelectionCGRect.height)
    presentViewController(contentView, animated: true, completion: nil)

}

func adaptivePresentationStyleForPresentationController(controller: UIPresentationController) -> UIModalPresentationStyle {
    return UIModalPresentationStyle.None
}

//ALSO:  On the third image, I placed the border imageview over the entire view controller in the storyboard, set padding to zero on all sides (autolayout).  It doesn't look good, though.

0 个答案:

没有答案