Ios 将图像与卡片翻转动画相结合
我正在尝试使用以下功能组合图像并翻转它们:Ios 将图像与卡片翻转动画相结合,ios,swift,Ios,Swift,我正在尝试使用以下功能组合图像并翻转它们: UIView.transitionFromView(self.frontImageView, toView: self.backImageView, duration: 1, options: UIViewAnimationOptions.TransitionFlipFromLeft, completion: nil) 这是使用swift。我有2个视图,它工作得很好。我希望backImageView是看起来像空白卡片的卡片与字母或图像的组合 我看到了
UIView.transitionFromView(self.frontImageView, toView: self.backImageView, duration: 1, options: UIViewAnimationOptions.TransitionFlipFromLeft, completion: nil)
这是使用swift。我有2个视图,它工作得很好。我希望backImageView
是看起来像空白卡片的卡片与字母或图像的组合
我看到了几篇关于使用UIGraphicsGetImageFromCurrentImageContext()组合图像的帖子。
我认为,当我对字母进行此操作时,会减慢应用程序的速度
下面是使用的代码(Card是UIView的一个子类)
问题是,有没有更好的办法?快一点的?我相信组合图像可能是比我可能错过的简单的东西更慢的选择
func combineImages( card: Card ) -> UIImage
{
let bottomImage: UIImage = UIImage( named: "cardFront" )!
var textColor: UIColor = UIColor.blackColor()
var textFont: UIFont = UIFont(name: "Muli", size: 120 )!
UIGraphicsBeginImageContext( bottomImage.size )
let textFontAttributes = [
NSFontAttributeName: textFont,
NSForegroundColorAttributeName: textColor,
]
bottomImage.drawInRect( CGRectMake(0, 0, bottomImage.size.width, bottomImage.size.height) )
var rect: CGRect = CGRectMake( 50, 48, 380, 360 )
var drawText = "\( card.pictureName )"
drawText.drawInRect( rect, withAttributes: textFontAttributes )
// Create a new image out of the images we have created
var newImage: UIImage = UIGraphicsGetImageFromCurrentImageContext()
// End the context now that we have the image we need
UIGraphicsEndImageContext()
return newImage
}