佚名通过本文主要向大家介绍了taylor swift图片,taylor swift高清图片,霉霉taylor swift图片,taylor swift,taylor swift演唱会等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com
问题:taylor swift图片 (swift)有关图片旋转,到底是那里作错了
描述:
解决方案1:
描述:
func scrollViewDidScroll(scrollView: UIScrollView) {
// 若设置了contentInset.top,此时contentOffset.y = -contentInset.top - realOffset
let contentOffsetY = scrollView.contentOffset.y
// real scroll offset
let totalOffsetY = scrollView.contentInset.top + contentOffsetY
print("contentOffsetY:\(contentOffsetY), totalOffsetY:\(totalOffsetY)")
if let headerView = headerView {
var size = headerView.frame.size
size.height = headerViewHeight - totalOffsetY
headerView.frame = CGRectMake(0, contentOffsetY, size.width, size.height)
addImageView.frame = CGRectMake(self.view.frame.size.width / 2 - 20 , size.height - 50, 40, 40)
var rad:Float = Float(size.height) / 180 * Float(M_PI)
print(rad)
addImageView.transform = CGAffineTransformMakeRotation(CGFloat(rad))
}
}
我只想让图片 顺时针 或 逆时间的转,但,感觉好像不是以X或Y轴为中心,是以Z轴在旋转,查了一下资料,也都大约是这个写法,我试了好多种写法,都这样,是不是有什么属性没设到的,求解
正确
错误
解决方案1:
上面这段程式其实是对的
但 当imageview 移动 跟 旋转不能作在一起
addImageView.frame = CGRectMake(self.view.frame.size.width / 2 - 20 , size.height - 50, 40, 40) //移动
addImageView.transform = CGAffineTransformMakeRotation(CGFloat(rad)) //旋转
原因为何,我也不知道 但事实証明了,两段分开时,都是正确的,包含旋转也是正确的
当写在一起的时候,就错了
所以,必须有一个View 掛载 imageview 然后,针对 imageview来作旋转,UIView来作移动,就好啦~