ÉèΪÊ×Ò³ ¼ÓÈëÊÕ²Ø

TOP

UIImageview and UIImage ֮Swiftѧϰ
2015-11-21 01:05:07 À´Ô´: ×÷Õß: ¡¾´ó ÖРС¡¿ ä¯ÀÀ:2´Î
Tags£ºUIImageview and UIImage Swift ѧϰ

//

// ViewController.swift

// UIImageview and UIImage

//

// Created by Mac on 15/4/12.

// Copyright (c) 2015Äê BSY. All rights reserved.

//

?

import UIKit

?

class ViewController: UIViewController {

?

override func viewDidLoad() {

super.viewDidLoad()

// ±¾µØÍ¼Æ¬µÄ¼ÓÔØ

// self .addimage()

?

//¼ÓÔØÍøÂçͼƬ£¨·Ç±¾µØ£©

self.addRemoteImageView()

}

?

func addimage()

{

// ³õʼ»¯uiimageview and uiimage

var uimageview = UIImageView(frame: CGRectMake(35, 100, 300, 300))

//ÉèÖüÓÔØÒ»Õű¾µØÍ¼Æ¬

let image = UIImage(named:"cat.jpg")

//°Ñ¼ÓÔØºÃµÄͼƬ¶ª¸øimageviewÖеÄimageÏÔʾ

uimageview.image = image

//°Ñuiimageview¼ÓÔØµ½¸¸¿Ø¼þÉÏ£¬Ò²¾ÍÊÇself.view

self.view.addSubview(uimageview)

?

?

?

?

}

//¼ÓÔØÍøÂçͼƬ£¨·Ç±¾µØ£©

func addRemoteImageView()

{

var imageView = UIImageView(frame: CGRectMake(35, 100, 300, 300))

// ͼƬµØÖ·

let strUrl = "https://www.cppentry.com/upload_files/article/49/1_q4ua8__.jpg"

//url

let url = NSURL(string: strUrl)

//ͼƬÊý¾Ý

var data = NSData(contentsOfURL:url!)

//ͨ¹ýµÃµ½Í¼Æ¬Êý¾ÝÀ´¼ÓÔØ

let image = UIImage(data: data!)

//°Ñ¼ÓÔØµ½µÄͼƬ¶ª¸øimageViewµÄimageÏÖʵ

imageView.image = image

?

//±ß¿òÑÕÉ«ÉèÖÃ

imageView.layer.borderColor = UIColor.redColor().CGColor

//±ß¿òµÄ¿í¶ÈÉèÖÃ

imageView.layer.borderWidth = 2

?

//Ô²½ÇµÄÉèÖÃ

imageView.layer.cornerRadius = 150

?

// ×îÖ÷ÒªµÄÒ»¾ä

imageView.layer.masksToBounds = true

//°Ñuiimageview¼ÓÔØµ½¸¸¿Ø¼þÉÏ£¬Ò²¾ÍÊÇself.view

self.view.addSubview(imageView)

?

?

?

?

?

}

override func didReceiveMemoryWarning() {

super.didReceiveMemoryWarning()

// Dispose of any resources that can be recreated.

}

?

?

}

?

¡¾´ó ÖРС¡¿¡¾´òÓ¡¡¿ ¡¾·±Ìå¡¿¡¾Í¶¸å¡¿¡¾Êղء¿ ¡¾ÍƼö¡¿¡¾¾Ù±¨¡¿¡¾ÆÀÂÛ¡¿ ¡¾¹Ø±Õ¡¿ ¡¾·µ»Ø¶¥²¿¡¿
·ÖÏíµ½: 
ÉÏһƪ£ºLeetCode¨DSet Matrix Zeroes ¾ØÕ.. ÏÂһƪ£ºPOJ 2352 star £¨Ê÷×´Êý×飩

ÆÀÂÛ

ÕÊ¡¡¡¡ºÅ: ÃÜÂë: (ÐÂÓû§×¢²á)
Ñé Ö¤ Âë:
±í¡¡¡¡Çé:
ÄÚ¡¡¡¡ÈÝ: