//

//  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. python数据库(mysql)操作

    一.软件环境 python环境默认安装了sqlite3,如果需要使用sqlite3我们直接可以在python代码模块的顶部使用import sqlite3来导入该模块.本篇文章我是记录了python操 ...

  2. 【Swift学习】Swift编程之旅---属性(十四)

    属性关联特定类.结构或枚举的值,存储属性将存储常量和变量作为实例的一部分,计算属性用于计算一个值,而不进行存储.计算属性可以用于类.结构体和枚举里,存储属性只能用于类和结构体.存储属性和计算属性通常用 ...

  3. angularjs中的页面访问权限设置

    11月在赶一个项目,这阵子比较忙,挤挤时间更一篇博客吧,如标题所述说说在ng中页面访问权限控制的问题,水平有限各位看官见谅: 在以往的项目中,前后端常见的配合方式是前端提供页面和ui加一点DuangD ...

  4. QQ--模拟登录

    QQ--模拟登录 使用PC端模拟登录,主要使用的QQ空间登录地址测试. 首先,QQHelper的创建. #region Helper /// <summary> /// Helper // ...

  5. 炉石传说 C# 开发笔记 (初版)

    法术资料说明 1.资料的准备 从GitHub上面获得的工程里面,是没有XML卡牌资料配置的,这个是需要你自己生成的. 打开炉边处说的客户端 然后按下  卡牌资料生成 将炉石资料文件设定为 Github ...

  6. 【Java每日一题】20161128

    package Nov2016; import java.util.ArrayList; import java.util.List; public class Ques1128 { public s ...

  7. swipe.js 2.0 轻量级框架实现mobile web 左右滑动

    属性总结笔记如下: <style> .swipe { overflow: hidden; //隐藏溢出 清楚浮动 visibility: hidden; //规定元素不可见 (可以设置,当 ...

  8. Scalaz(42)- Free :FreeAp-Applicative Style Programming Language

    我们在前面花了几期时间讨论Free Monad,那是因为FP既是Monadic programming,Free Monad是FP模式编程的主要方式.对我们来说,Free Monad代表着fp从学术探 ...

  9. Greenplum(GP)常见问题,注意事项

    1.在安装过程中,出现的 source /usr/local/greenplum-db/greenplum_path.sh 不要写到profile或者./bashrc文件中 因为该句会导致python ...

  10. jquery 集合操作

    修剪字符串 $.trim(value) 功能: 删除传入的字符串开头和结尾的空白 [空白]匹配js正则中的\s,也就是包括空白,换行,回车,制表符,换页以及Unicode字符\u00A0 返回值: 返 ...