不下载你会懊悔的~~

下载地址: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. openstack中glance组件images的全部python API 汇总

    感谢朋友支持本博客,欢迎共同探讨交流.因为能力和时间有限.错误之处在所难免,欢迎指正! 假设转载,请保留作者信息. 博客地址:http://blog.csdn.net/qq_21398167 原博文地 ...

  2. C#基础:关键字和数据类型

    [关键字]  #region 和 #endregion 关键字可以折叠代码  checked 用于整型算术运算时控制当前环境中的溢出检查  unchecked 操作符用于整型算术运算时控制当前环境中的 ...

  3. shell读取文件参数

    环境 csh 说明 通常我们需要使用使用shell脚本处理一些事务,每次调用shell都需要添加参数. 如果重复调用多次这个shell脚本,我们可以将参数存入指定文件,循环得到参数. shell脚本( ...

  4. 阿里云主机SSD实例磁盘测试及IO调度算法调整

    测试背景及环境说明 阿里云ECS 主机配置: 4C8G root@zabbix-master:~# grep -i "model name" /proc/cpuinfo model ...

  5. DEV GridControl 导出到Excel

    SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.Title = "导出Excel"; sa ...

  6. (转)添加服务引用和添加Web引用对比

    在WindowsForm程序中添加服务引用和Web引用对比 为了验证书上有关Visual Studio 2010添加服务引用和Web引用的区别,进行实验. 一.建立一个Web服务程序项目新建项目,选择 ...

  7. 拉姆达表达式(Lambda Expressions)

    上面两种写法是一样的 ,拉姆达表达式也是一种委托, 但引用的是匿名方法

  8. 华为oj - 统计大写字母个数

    练手而已. 给初学者参考 #include <stdio.h> #include <string.h> int main(void) { char string[200]={' ...

  9. g++实用技巧

    查看代码文件包含了哪些头文件 g++ -M FileName

  10. C#设置鼠标在控件上面时,改变光标形状

    //设置鼠标在控件上面时,改变光标形状 private void pictureBox_macroLogo_MouseHover(object sender, System.EventArgs e) ...