加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

swift 学习 3

发布时间:2020-12-14 01:47:44 所属栏目:百科 来源:网络整理
导读:1、UIPopover 使用 在要使用POPover的ViewController 继承 UIPopoverPresentationControllerDelegate 使用方式: let storyboard : UIStoryboard = UIStoryboard(name: "Main",bundle: nil) let contentViewController :PopContainerViewController = storyb

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)

2UIScrollView 使用

在要使用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//内容窗口大小

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读