I know you can do this with a UIImageView, but can it be done to a UIImage? I want to have the animation images array property of a UIImageView to be an array of the same image but with different opacities. Thoughts?
相关问题
- How to fix IE ClearType + jQuery opacity problem i
- Core Data lightweight migration crashes after App
- How can I implement password recovery in an iPhone
- State preservation and restoration strategies with
- “Zero out” sensitive String data in Swift
相关文章
- 现在使用swift开发ios应用好还是swift?
- UITableView dragging distance with UIRefreshContro
- TCC __TCCAccessRequest_block_invoke
- Where does a host app handle NSExtensionContext#co
- Swift - hide pickerView after value selected
- How do you detect key up / key down events from a
- didBeginContact:(SKPhysicsContact *)contact not in
- Attempt to present UIAlertController on View Contr
Based on Alexey Ishkov's answer, but in Swift
I used an extension of the UIImage class.
Swift 2:
UIImage Extension:
To use:
Swift 3 / Swift 4:
Note that this implementation returns an optional UIImage. This is because in Swift 3
UIGraphicsGetImageFromCurrentImageContext
now returns an optional. This value could be nil if the context is nil or what not created withUIGraphicsBeginImageContext
.UIImage Extension:
To use:
Hey hey thanks from Xamarin user! :) Here it goes translated to c#
Usage example:
Set the opacity of its view it is showed in.
Use this in an animation. You can change the alpha in an animation for an duration.
there is much easier solution:
I realize this is quite late, but I needed something like this so I whipped up a quick and dirty method to do this.
I just needed to do this, but thought Steven's solution would be slow. This should hopefully use graphics HW. Create a category on UIImage: