1、UIPopover 使用
在要使用POPover的ViewController 继承UIPopoverPresentationControllerDelegate
使用方式:
let storyboard : UIStoryboard = UIStoryboard(name: "Main",bundle: nil) let contentViewController :PopContainerViewController = storyboard.instantiateViewControllerWithIdentifier( "popContainerView") as! PopContainerViewController contentViewController.modalPresentationStyle=UIModalPresentationStyle.Popover contentViewController.preferredContentSize = contentViewController.view.bounds.size; let popPC:UIPopoverPresentationController=contentViewController.popoverPresentationController! popPC.permittedArrowDirections=UIPopoverArrowDirection.Left let originX:CGFloat = sender.layer.frame.width let originY:CGFloat = sender.layer.frame.height/2.0//设置箭头指向的位置 popPC.sourceRect.origin=CGPoint(x:originX,y:originY) popPC.delegate=self; popPC.sourceView=sender as? UIView presentViewController(contentViewController,animated: true,completion: nil)
2、UIScrollView 使用
在要使用UIScrollView 的ViewController 继承UIScrollViewDelegate
scrollView.frame.size=view.frame.size//设置scrollView 的窗口大小 scrollView.backgroundColor=UIColor.greenColor()//用于调试 scrollView.delegate=self scrollView.scrollEnabled=true <span style="white-space:pre"> </span>scrollView.contentSize=size//内容窗口大小原文链接:https://www.f2er.com/swift/325888.html