码迷,mamicode.com
首页 > 其他好文 > 详细

UIView

时间:2014-12-04 21:14:22      阅读:180      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   io   ar   color   os   sp   for   

//

//  ViewViewController.swift

//  UIControlDemo

//

//  Created by  on 14/12/1.

//  Copyright (c) 2014 马大哈. All rights reserved.

//

 

import UIKit

 

class ViewViewController: BaseViewController {

    var redView: UIView?

    override func viewDidLoad() {

        super.viewDidLoad()

 

        redView = UIView(frame: CGRectMake(0, 330, self.view.frame.size.width, self.view.frame.size.height-350))

        redView?.backgroundColor = UIColor.redColor()

        self.view.addSubview(redView!)

        

        var button = UIButton.buttonWithType(UIButtonType.Custom) as UIButton

        button.backgroundColor = UIColor.whiteColor()

        button.frame = CGRectMake(30, 50, 250, 50)

        button.setTitleColor(UIColor.blackColor(), forState:.Normal)

        button.setTitle("点我,移除所有子视图", forState: UIControlState.Normal)

        button.addTarget(self, action: "buttonMethod:", forControlEvents: UIControlEvents.TouchUpInside)

        redView!.addSubview(button)

    }

    

    func buttonMethod(touchButton:UIButton){

        var subView:UIView?

        for subView in redView!.subviews{

            subView.removeFromSuperview()

        }        

        UIView.transitionWithView(redView!, duration: 5.0, options: UIViewAnimationOptions.TransitionFlipFromLeft, animations: {

            }, completion: {completed in

                self.redView!.backgroundColor = UIColor.blackColor()

        })

    }

    

    override func didReceiveMemoryWarning() {

        super.didReceiveMemoryWarning()

        // Dispose of any resources that can be recreated.

    }

}

 

效果图

bubuko.com,布布扣bubuko.com,布布扣

 

UIView

标签:style   blog   http   io   ar   color   os   sp   for   

原文地址:http://www.cnblogs.com/madaha/p/4143726.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!