Ios Xcode:UIWebView用于刷新网站缩放时未居中的动画
我用Xcode和Swift创建了一个iOS应用程序。我使用以下代码进行拉取刷新:Ios Xcode:UIWebView用于刷新网站缩放时未居中的动画,ios,xcode,animation,uiwebview,pull-to-refresh,Ios,Xcode,Animation,Uiwebview,Pull To Refresh,我用Xcode和Swift创建了一个iOS应用程序。我使用以下代码进行拉取刷新: func pullToRefresh() { self.homewebview.reload() } func addRefreshControl() { refreshControl = UIRefreshControl() refreshControl.attributedTitle = NSAttributedString(string: "Please wait a mome
func pullToRefresh() {
self.homewebview.reload()
}
func addRefreshControl() {
refreshControl = UIRefreshControl()
refreshControl.attributedTitle = NSAttributedString(string: "Please wait a moment…")
refreshControl.addTarget(self, action: #selector(FirstViewController.pullToRefresh), forControlEvents:.ValueChanged)
self.homewebview.scrollView.addSubview(refreshControl)
}
它工作得很好,动画也显示出来了。但是,当用户放大(放大或缩小)网站并拖动以刷新动画(旋转滚轮,“请稍等…”文本)时,根据放大网站的实际显示面,文本不会居中(水平)显示
有人知道怎么解决吗
contentInsets
,如果是,则将布局约束/布局定位设置为refreshControl.superView
,并设置偏移量tableView.refreshControl=refreshControl
,而不是将其作为子视图添加例如,如果您有左右插入
leftrightsinset=CGFloat(value)
然后,您可以使用以下代码段来集中刷新控件:
refreshControl.bounds = CGRect(x: leftRightInset,
y: refreshControl.bounds.origin.y,
width: refreshControl.bounds.width,
height: refreshControl.bounds.height)