您的位置:首页 > 移动开发 > Swift

swift 学习 3

2015-09-23 16:27 411 查看
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//内容窗口大小
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: