So I looked around the developer library on apple's site and I couldn't find any documentation that said how to state what file (like a png) to use for a UIImage using the swift language. So I try experimenting with this code:
class ViewController: UIViewController { @IBOutlet var maintitle: UIImageView var bigtitle: UIImage! var smalltitle: UIImage! override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. func startAnimating(){ var animatedtitle: AnyObject[] = [bigtitle, smalltitle] var animationDuration: NSTimeInterval = 0.15 var animationRepeatCount: Int = 0 } }
What I was trying to do there was animate a never ending series of two images. I defined two UIImages (bigtitle & small title) and was wondering how I define wat .png's to use for those UIImage's. I know this is a very basic and novice question but any help would be enjoyed.
An object that manages image data in your app.
For example: UIImage *img = [[UIImage alloc] init]; [img setImage:[UIImage imageNamed:@"anyImageName"]]; My UIImage object is declared in .
UIImage contains the data for an image. UIImageView is a custom view meant to display the UIImage .
Once a UIImage is created, the image data is loaded into memory and no longer connected to the file on disk. As such, the file can be deleted or modified without consequence to the UIImage and there is no way of getting the source path from a UIImage.
Even though you are using Swift, all the classes that come from UIKit
and other libraries still are written in Objective-C.
There is no difference in the interfaces to these libraries, just the syntax.
In this case, you need to use the object construction syntax:
var image = UIImage(named:"ImageName")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With