iOS Development--ui Article Swift &uiimageview

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.