不下载你会懊悔的~~

下载地址:https://github.com/HunkSmile/Swift.git

// UILabel
var label = UILabel(frame: self.view.bounds)
label.backgroundColor = UIColor.clearColor()
label.textAlignment = NSTextAlignment.Center
label.font = UIFont.systemFontOfSize(36)
label.text = "Hello, Swift"
self.view.addSubview(label)
// UIButton
var button = UIButton.buttonWithType(UIButtonType.System) as? UIButton
button!.frame = CGRectMake(110.0, 120.0, 100.0, 50.0)
button!.backgroundColor = UIColor.grayColor()
button?.setTitleColor(UIColor.redColor(), forState: UIControlState.Normal)
button!.setTitleColor(UIColor.whiteColor(), forState: UIControlState.Highlighted)
button?.setTitle("Touch Me", forState: UIControlState.Normal)
button?.setTitle("Touch Me", forState: UIControlState.Highlighted)
button?.addTarget(self, action: "buttonAction:", forControlEvents: UIControlEvents.TouchUpInside)
button!.tag = 100
self.view.addSubview(button)
// UIImageView
var image = UIImage(named: "swift-hero.png")
var imageView = UIImageView(frame: CGRectMake((CGRectGetWidth(self.view.bounds) - image.size.width) / 2.0, 120.0, image.size.width,
image.size.height))
imageView.image = image
self.view.addSubview(imageView)
// UISlider
var slider = UISlider(frame:CGRectMake(60.0, 120.0, 200.0, 30.0))
self.view.addSubview(slider)
// UIWebView
var webView = UIWebView(frame:self.view.bounds)
var url = NSURL(string: "http://caipiao.m.taobao.com")
var request = NSURLRequest(URL: url)
webView.loadRequest(request)
self.view.addSubview(webView)
// UISegmentedControl
var segmentControl = UISegmentedControl(items:["A", "B", "C", "D"])
segmentControl.frame = CGRectMake(110.0, 120.0, 100.0, 30.0)
self.view.addSubview(segmentControl)
// UISwitch
var switchControl = UISwitch(frame:CGRectMake(130.0, 120.0, 100.0, 30.0))
switchControl.on = true
self.view.addSubview(switchControl)
// UITextField
var textField = UITextField(frame:CGRectMake(60.0, 120.0, 200.0, 30.0))
textField.backgroundColor = UIColor.lightGrayColor()
textField.placeholder = "input text"
self.view.addSubview(textField)
// UIScrollView
var scrollView = UIScrollView(frame:CGRectMake(60.0, 120.0, 200.0,
200.0))
scrollView.pagingEnabled = true
scrollView.showsVerticalScrollIndicator = false
self.view.addSubview(scrollView)
var fX: CGFloat = 0.0
for(var i = 0; i < 3; ++i)
{
var view = UIView(frame:CGRectMake(fX, 0.0, 200.0, 200.0))
fX += 200.0
view.backgroundColor = UIColor.redColor()
scrollView.addSubview(view)
}
scrollView.contentSize = CGSizeMake(3 * 200.0, 200.0)
self.view.addSubview(scrollView)
// UISearchBar
var searchBar = UISearchBar(frame:CGRectMake(10.0, 120.0, 300.0,
30.0))
searchBar.showsCancelButton = true
searchBar.searchBarStyle = UISearchBarStyle.Minimal // Default, Prominent, Minimal
self.view.addSubview(searchBar)
// UIPageControl
var pageControl = UIPageControl(frame:CGRectMake(60.0, 120.0, 200.0, 200.0))
pageControl.numberOfPages = 5
pageControl.currentPageIndicatorTintColor = UIColor.blackColor()
pageControl.pageIndicatorTintColor = UIColor.redColor()
self.view.addSubview(pageControl)
// UIDatePicker
var datePicker = UIDatePicker(frame:CGRectMake(0.0, 120.0, 200.0, 200.0))
self.view.addSubview(datePicker)
// UIPickerView
var pickerView = UIPickerView(frame:CGRectMake(10.0, 120.0, 300.0, 200.0))
pickerView.delegate = self
pickerView.dataSource = self
self.view.addSubview(pickerView)
// UIProgressView
var progressView = UIProgressView(progressViewStyle:UIProgressViewStyle.Default)
progressView.frame = CGRectMake(10.0, 120.0, 300.0, 30.0)
progressView.setProgress(0.8, animated: true)
self.view.addSubview(progressView)
// UITextView
var textView = UITextView(frame:CGRectMake(10.0, 120.0, 300.0, 200.0))
textView.backgroundColor = UIColor.lightGrayColor()
textView.editable = false
textView.font = UIFont.systemFontOfSize(20)
textView.text = "Swift is an innovative new programming language for Cocoa and Cocoa Touch. Writing code is interactive and fun, the syntax is concise yet expressive, and apps run lightning-fast. Swift is ready for your next iOS and OS X project — or for addition into your current app — because Swift code works side-by-side with Objective-C."
self.view.addSubview(textView)
// UIToolbar
var toolBar = UIToolbar(frame:CGRectMake(60.0, 120.0, 200.0, 30.0))
var flexibleSpace = UIBarButtonItem(barButtonSystemItem:UIBarButtonSystemItem.FlexibleSpace, target:nil, action:nil)
var barBtnItemA = UIBarButtonItem(title: "A", style:UIBarButtonItemStyle.Plain, target:nil, action:nil)
var barBtnItemB = UIBarButtonItem(title: "B", style:UIBarButtonItemStyle.Plain, target:nil, action:nil)
var barBtnItemC = UIBarButtonItem(title: "C", style:UIBarButtonItemStyle.Plain, target:nil, action:nil)
var barBtnItemD = UIBarButtonItem(title: "D", style:UIBarButtonItemStyle.Plain, target:nil, action:nil)
toolBar.items = [flexibleSpace, barBtnItemA, flexibleSpace, barBtnItemB, flexibleSpace, barBtnItemC, flexibleSpace, barBtnItemD, flexibleSpace]
self.view.addSubview(toolBar)
// UIActionSheet
var alertController = UIAlertController(title: "ActionSheet", message: "Message", preferredStyle: UIAlertControllerStyle.ActionSheet)
alertController.addAction(UIAlertAction(title: "Go Back", style: UIAlertActionStyle.Destructive, handler: nil))
self.presentViewController(alertController, animated: true, completion:nil)
// UIActivityIndicatorView
var activityIndicatorView = UIActivityIndicatorView(activityIndicatorStyle:UIActivityIndicatorViewStyle.Gray)
activityIndicatorView.frame = CGRectMake(140.0, 120.0, 40.0, 40.0)
activityIndicatorView.startAnimating()
self.view.addSubview(activityIndicatorView)
// UIAlertView
var alert = UIAlertController(title: "Title", message: String(format: "Result = %i", 10), preferredStyle: UIAlertControllerStyle.Alert)
alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler: nil))
self.presentViewController(alert, animated: true, completion: nil)
// UITableView
var tableView : UITableView?
self.tableView = UITableView(frame:self.view.frame, style:UITableViewStyle.Plain)
self.tableView!.delegate = self
self.tableView!.dataSource = self
self.tableView!.registerClass(UITableViewCell.self, forCellReuseIdentifier: "Cell")
self.view?.addSubview(self.tableView) // UITableViewDataSource Methods
func numberOfSectionsInTableView(tableView: UITableView!) -> Int
{
return 1
}
func tableView(tableView: UITableView!, numberOfRowsInSection section: Int) -> Int
{
return self.items!.count
}
func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell!
{
let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as UITableViewCell!
cell.accessoryType = UITableViewCellAccessoryType.DisclosureIndicator
cell.textLabel.text = self.items?.objectAtIndex(indexPath.row) as String return cell
}
// UITableViewDelegate Methods
func tableView(tableView: UITableView!, didSelectRowAtIndexPath indexPath: NSIndexPath!)
{
self.tableView!.deselectRowAtIndexPath(indexPath, animated: true)
}

Apple Swfit UI控件实现的更多相关文章

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

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

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

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

  3. ANDROID L——Material Design详解(UI控件)

    转载请注明本文出自大苞米的博客(http://blog.csdn.net/a396901990),谢谢支持! Android L: Google已经确认Android L就是Android Lolli ...

  4. WinForm/Silverlight多线程编程中如何更新UI控件的值

    单线程的winfom程序中,设置一个控件的值是很easy的事情,直接 this.TextBox1.value = "Hello World!";就搞定了,但是如果在一个新线程中这么 ...

  5. 富客户端 wpf, Winform 多线程更新UI控件

    前言 在富客户端的app中,如果在主线程中运行一些长时间的任务,那么应用程序的UI就不能正常相应.因为主线程要负责消息循环,相应鼠标等事件还有展现UI. 因此我们可以开启一个线程来格外处理需要长时间的 ...

  6. UI控件(复习一下)

    如何修改控件状态• 可见,确实需要经常修改控件状态• 那如何去修改控件的状态呢?方法很简单➢ 每一个UI控件都是一个对象➢ 修改UI控件的状态,其实就是修改控件对象的属性➢ 比如修改UILabel显示 ...

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

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

  8. 《深入理解Windows Phone 8.1 UI控件编程》基于最新的Runtime框架

    <深入理解Windows Phone 8.1 UI控件编程>本书基于最新的Windows Phone 8.1 Runtime SDK编写,全面深入地论述了最酷的UI编程技术:实现复杂炫酷的 ...

  9. (转).NET 4.5中使用Task.Run和Parallel.For()实现的C# Winform多线程任务及跨线程更新UI控件综合实例

    http://2sharings.com/2014/net-4-5-task-run-parallel-for-winform-cross-multiple-threads-update-ui-dem ...

随机推荐

  1. Stm32高级定时器(三)

    Stm32高级定时器(三) 1 互补输出和死区插入 1.1 死区:某个处于相对无效状态的时间或空间 本来OCX信号与OCXREF时序同相同步,OCXN信号与OCXREF时序反相同步.但为了安全考虑,以 ...

  2. linux 虚拟机centos64位_6.5+VM10 主机是固定IP局域网设置代理上网,虚机设置固定ip 图文详细步骤

    一种: 虚机是Desktop 安装 1.虚拟机—设置—网络适配器子选项—选择“桥接模式” 2.在虚拟机中选择系统(System)—首选项(Preferences)—网络连接(Network Conne ...

  3. CocoaPod安装

    http://www.360doc.com/content/14/0309/10/11029609_358970353.shtml http://www.bubuko.com/infodetail-4 ...

  4. IOS — 关于Socket传输文件需要自定义延时或者包大小的情况

    1. 首先导入头文件 #include <stdio.h> #include <errno.h> #include <string.h> #include < ...

  5. Java中的int和Integer

    代码: public class Test{ public static void main(String[] args){ Integer i01 = 59; int i02 = 59; Integ ...

  6. (原)torch7中添加新的层

    转载请注明出处: http://www.cnblogs.com/darkknightzh/p/6069627.html 参考网址: http://torch.ch/docs/developer-doc ...

  7. shell中的双括号表达式

    语法格式 (( expression )) expression可以是任何数学表达式,可以包含的操作符有: +  加 - 减 * 乘(无需转义) / 除 % 取余 ** 指数 == 等于 != 不等 ...

  8. 硬盘安装ubuntu

    本文记录在能够启动到GRUB2启动菜单的前提下硬盘安装ubuntu的方法. 14.04和16.04测试可用. 假设镜像文件放在GPT第一个分区,文件名为ubuntu.iso. 启动到GRUB2菜单后, ...

  9. 利用Azure高级存储搭建高性能Linux服务器(1)

    目前Azure针对虚拟机提供两种类型的存储,一种是标准存储,基于HDD的,一种是高性能存储Premium Storage(在下文中简称PS),基于SSD的.针对用户高性能,低延迟,I/O密集型的应用, ...

  10. [POJ] 2456 Aggressive cows (二分查找)

    题目地址:http://poj.org/problem?id=2456 最大化最小值问题.二分牛之间的间距,然后验证. #include<cstdio> #include<iostr ...