//

//  ViewController.swift

//  test

//

//  Created by chuangqu on 15/7/23.

//  Copyright (c) 2015年 theway. All rights reserved.

//

import UIKit

class ViewController: UIViewController {

override func viewDidLoad() {

super.viewDidLoad()

var lable = UILabel(frame: CGRectMake(120, 20, 100, 20))

lable.text = "小猪飞!"

lable.textColor = UIColor.blueColor()

lable.backgroundColor = UIColor.brownColor()

lable.textAlignment = NSTextAlignment.Center

lable.shadowColor = UIColor.grayColor()

lable.shadowOffset = CGSizeMake(-5, 5)

lable.font = UIFont(name: "zapfino", size: 20)

self.view.addSubview(lable)

var file = UITextField(frame: CGRectMake(120, 80, 100, 20))

file.text = "肖"

file.textColor = UIColor.blueColor()

self.view.addSubview(file)

var button:UIButton = UIButton.buttonWithType(UIButtonType.System)as!UIButton;

button.frame = CGRectMake(120, 150, 100, 80)

button.setTitle("猪fjygjyy", forState:UIControlState.Normal)

//        button.setImage(UIImage(named: "0"), forState: .Normal)

button.adjustsImageWhenHighlighted = false

button.setBackgroundImage(UIImage(named: "0"), forState: .Normal)//设置背景

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

self.view.addSubview(button)

segmented ()

/*

创建一个文本框

*/

var textfield = UITextField(frame: CGRectMake(10, 20, 100, 20))

textfield.borderStyle = UITextBorderStyle.RoundedRect//设置文本框为圆边圆角

textfield.placeholder = "yuebu"//设置提示语句

//        textfield.text = "hhhh"//设置默认值

textfield.adjustsFontSizeToFitWidth = true //设置当超出文本时文字省略方式

//        textfield.textAlignment = NSTextAlignment.Center//设置文字的水平对齐属性

//        textfield.contentVerticalAlignment = UIControlContentVerticalAlignment.Center//垂直对齐方式

//简写

//        textfield.returnKeyType = UIReturnKeyType.Go//设置键盘的返回键作用

textfield.contentVerticalAlignment = .Center

textfield.clearButtonMode = .WhileEditing

//        textfield.clearButtonMode = UITextFieldViewMode.UnlessEditing

//        textfield.clearButtonMode = .UnlessEditing

self.view.addSubview(textfield)

//        kaiguan()

img ()

animation ()

//         progess()

//        test()

// Do any additional setup after loading the view, typically from a nib.

}

override func didReceiveMemoryWarning() {

super.didReceiveMemoryWarning()

// Dispose of any resources that can be recreated.

}

func test() {

//        button.setTitle("小大", forState: UIControlState.Normal)//不能改变UI,需在UI线程中操作

println("我肾很好!")

}

func kaiguan (){

var uiswitch : UISwitch

uiswitch = UISwitch()

uiswitch.center = CGPointMake(100, 50)

uiswitch.on = true

self.view.addSubview(uiswitch)

}

func segmented (){

var items = ["张","萧","阿","姨"]//,UIImage(named: "icon")]

var seg = UISegmentedControl(items: items)

seg.center = self.view.center

seg.selectedSegmentIndex = 1

self.view.addSubview(seg)

}

func img (){

var imge = UIImageView(image: UIImage(named: "3"))

imge.frame = CGRectMake(90,350, 200, 200)

self.view.addSubview(imge)

}

var imageview : UIImageView!

func animation (){

imageview = UIImageView()

imageview.frame = CGRectMake(90,350, 200, 200)

//帧动画设置

//        imageview.animationImages = [UIImage(named:"0"),UIImage(named:"3")]

//设置变化时间

imageview.animationDuration = 0.5

self.view.addSubview(imageview)

}

override func viewWillAppear(animated: Bool) {

super.viewWillAppear(animated)

imageview.startAnimating()

}

override func viewWillDisappear(animated: Bool) {

super.viewWillDisappear(animated)

imageview.stopAnimating()

}

//    override func DidLoad() {

//        super.viewDidLoad()

//        imageview = UIImageView()

//        imageview.frame = CGRectMake(90,350, 200, 200)

//        //帧动画设置

//        imageview.animationImages = [UIImage(named: "3"),UIImage(named: "3"),UIImage(named: "3")]

//        //设置变化时间

//        imageview.animationDuration = 0.5

//        self.view.addSubview(imageview)

//

//    }

func progess(){

var progres = UIProgressView(progressViewStyle: UIProgressViewStyle.Default)

progres.center = self.view.center

progres.progress = 0.5

progres.setProgress(0.8, animated: true)

self.view.addSubview(progres)

var alert = UIAlertView()

alert.frame = CGRectMake(200, 150, 100, 100)

alert.title = "刘大神帅不"

alert.message = "是/否"

alert.addButtonWithTitle("是")

alert.addButtonWithTitle("否")

alert.cancelButtonIndex = 0

alert.delegate = self

alert.show()

hhh(alert, clickedButtonAlertIndex: alert.cancelButtonIndex)

}

func hhh(alert:UIAlertView,clickedButtonAlertIndex button:Int){

if button == alert.cancelButtonIndex {

print("不帅")

}

else{

print("不帅!!!!")

}

}

}

swift学习之UI控件(一)的更多相关文章

  1. 用swift创建各种UI控件【iSwifting社区】

    为了方便大家学习,www.iSwifting.com社区为大家准备了创建各种UI控件的代码.開始看着语法可能有些别扭,当用习惯了,就认为还是非常不错的. 社区还添加了问答专区.有问题的朋友.虽然问.大 ...

  2. Swift学习之熟悉控件

    最近是比较清闲一些的,对于一个开发者来说,这也是一个很好的充电机会.以前做项目都是使用Objective-C去开发,但我们都知道,Swift语言从2014年的出现到现在,一步一步变的完善,渐渐变的受欢 ...

  3. 安卓学习之--UI控件用法 单选 按钮 下拉框

    1.单选 .RadioGroup 可将各自不同的RadioButton ,设限于同一个Radio 按钮组,同一个RadioGroup 组里的按钮,只能做出单一选择(单选题). <RadioGro ...

  4. Android学习路-UI控件

  5. Swift UI控件详细介绍(上)

    UI控件 首先介绍一下AppDelegate.swift@UIApplicationMain 调用了OC中的UIApplicationMain函数:UIApplicationMain是iOS应用程序的 ...

  6. iOS基础UI控件介绍-Swift版

    iOS基础UI控件总结 iOS基础控件包括以下几类: 1.继承自NSObject:(暂列为控件) UIColor //颜色 UIImage //图像 2.继承自UIView: 只能相应手势UIGest ...

  7. IOS学习资源收集--开发UI控件相关

    收集的一些本人了解过的iOS开发UI控件相关的代码资源(本文持续补充更新) 内容大纲: 1.本人在github上也上传了我分装好的一些可重复利用的UI控件 2.计时相关的自定义UILabel控件 正文 ...

  8. AppleWatch___学习笔记(二)UI布局和UI控件

    1.UI布局 直接开发,你会发现Apple Watch并不支持AutoLayout,WatchKit里有个类叫做WKInterfaceGroup,乍一看像是UIView,但是这货其实是用来布局的.从 ...

  9. ios 中的UI控件学习总结(1)

    UIKit框架提供了非常多功能强大又易用的UI控件 下面列举一些在开发中可能用得上的UI控件 UIButton 按钮 UILabel 文本标签 UITextField 文本输入框 UIImageVie ...

随机推荐

  1. 【Android】做一款类似我要当学霸里的学习监督的APP

    我要当学霸这款App有个学习监督的功能,当你启动它的时候,你将无法使用其他App,以此达到帮助人提高自觉性,起到监督学习的效果.最近和同学做了个小App,正好有这个功能,所以就来说说它是怎么实现的. ...

  2. SQL--使用NewID函数,创建GUID列

    USE master GO IF EXISTS (SELECT * FROM sysdatabases WHERE name='DB_Temp') DROP DATABASE DB_Temp GO C ...

  3. JavaScript基础—闭包,事件

    Js基础-闭包,事件 1:js中的闭包 概念:在一个函数内部又定义了一个函数,内部函数能访问到外部函数作用域范围内的变量,这时这个内部函数就叫做闭包,无论这个内部函数在哪里被调用都能访问到外部函数作用 ...

  4. android The connection to adb is down 错误信息

    之前运行eclipse执行android应用都没问题,今天突然出问题了,控制台报错: The connection to adb is down, and a severe error has occ ...

  5. iOS阶段学习第30天笔记( UIViewController—Delegate(代理) )

    iOS学习(UI)知识点整理 一.UIViewController的介绍 1)概念:UIViewController 即视图控制器,用来管理和控制页面跳转的一个类 ,iOS里面采用了MVC的体系结构, ...

  6. SQL Server XML转Table

    前言 在SQL Server中有时候我们需要传人一个Table过去,然后可以在存储过程中批量更新,批量的获取相应数据. 但存储过程的参数是固定,所以这里我们可以变通的传人xml类型的参数,然后在存储过 ...

  7. .net IO异步和Producer/Consumer队列实现一分钟n次http请求

    简介 最近工作中有一个需求:要求发送http请求到某站点获取相应的数据,但对方网站限制了请求的次数:一分钟最多200次请求. 搜索之后,在stackoverflow网站查到一个类似的问题..但里面用到 ...

  8. Service随系统启动运行

    Android系统启动时,会发出android.intent.action.BOOT_COMPLETED广播,定义一个类继承自BroadcastReceiver,监听该广播,并在收到该广播时启动Ser ...

  9. 2016暑假多校联合---GCD

    Problem Description Give you a sequence of N(N≤100,000) integers : a1,...,an(0<ai≤1000,000,000). ...

  10. CAS客户端服务器端配置步骤

    来自我的个人网站:http://lkf.22web.org/ cas介绍: CAS 是 Yale 大学发起的一个开源项目,旨在为 Web 应用系统提供一种可靠的单点登录方法,CAS 在 2004 年 ...