Uiimageview
1 Overridefunc viewdidload () {2 super.viewdidload ()3 4Titlelabel.text =titlestring5 6 //Create an image view with coordinates and size7var Imageview:uiimageview = Uiimageview (Frame:cgrectmake ( -, -, -, -))8Imageview.image = UIImage (named:"Swiftclassweixin.png")9 Self.view.addSubview (ImageView)Ten One A //Initialize size by picture -var Imageview2:uiimageview = Uiimageview (Image:uiimage (named:"Swiftclassweixin.png")) -Imageview2.frame = CGRectMake ( -, $, -, -) the Self.view.addSubview (IMAGEVIEW2) - - -var image:uiimage! = UIImage (named:"Swiftclassweixin.png") + - + //get the picture from the file path, type refers to the file suffix A at //Define Path -Let path:string? = Nsbundle.mainbundle (). Pathforresource ("SwiftClassWeiXin1", OfType:"PNG") - - //Unpacking - ifLet svalue =Path { -var newimage:uiimage! =UIImage (Contentsoffile:svalue) in } - to + //get pictures from network address - the //define an address string constant *Let imageurlstring:string ="Http://www.iphonetrain.com/core/res/images/logo.png"; $ Panax Notoginseng //convert to Nsurl object by string type -Let url:nsurl! = Nsurl (string: imageurlstring) the + //getting data streams from the network Avar data:nsdata! =NSData (Contentsofurl:url) the + //initializing a picture with a stream of data -var newimage2:uiimage! =UIImage (data:data) $ $Imageview2.image =NewImage2 - - theImageview2.contentmode =Uiviewcontentmode.center - Wuyi the - //define a picture an array group Wuvar imagearray:[uiimage]! = [ -UIImage (named:"1kar1.png")!, AboutUIImage (named:"1kar2.png")!, $UIImage (named:"1kar3.png")!, -UIImage (named:"1kar4.png")!, -UIImage (named:"1kar5.png")!, -UIImage (named:"1kar6.png")!, AUIImage (named:"1kar7.png")!, +UIImage (named:"1kar8.png")!, theUIImage (named:"1kar9.png")!, -UIImage (named:"1kar10.png")!, $UIImage (named:"1kar11.png")!, theUIImage (named:"1kar12.png")!, theUIImage (named:"1kar13.png")!] the the - //set the Animationimages property of an image view inImageview2.animationimages =Imagearray the the //Set Animation time AboutImageview2.animationduration =5.0 the the //set the number of animations to play theImageview2.animationrepeatcount =2 + - //start playing animations the imageview2.startanimating ()Bayi the the //[Self.aimageview Setisaccessibilityelement:yes]; - //[Self.aimageview SetAccessibilityLabel:self.title]; - the}
iOS Development--ui Swift article &uiimageview