使用Swift开发iOS项目、UI创建、方法调用
//1、root控制器的创建
var rootCtrl =RootViewController()
var root:UINavigationController =UINavigationController(rootViewController: rootCtrl)
self.window!.rootViewController =
root
//2、tab控制器的创建
var tab =UITabBarController()
tab.tabBar.barTintColor =UIColor.blackColor()
tab.viewControllers = [oneCtrl, twoCtrl, threeCtrl, fourCtrl, fiveCtrl]
self.window!.rootViewController =
tab
//3、声明属性
var tableView:UITableView?
//4、抽出TableView的创建方法
func _initTableView(){
//TableView的创建和设置
))
self.tableView!.delegate =self
self.tableView!.dataSource =self
self.tableView!.autoresizingMask = UIViewAutoresizing.FlexibleHeight
|UIViewAutoresizing.FlexibleWidth
self.tableView!.registerClass(UITableViewCell.self,
forCellReuseIdentifier:"cell")
self.view?
.addSubview(self.tableView)
self.tableView!.separatorColor =UIColor.cyanColor()
}
//dataSource 返回100个row
func tableView(tableView:UITableView!, numberOfRowsInSection section: Int) ->Int
{
}
//cell的创建
func tableView(tableView:UITableView!, cellForRowAtIndexPath indexPath:NSIndexPath!) ->UITableViewCell!
{
let cell = tableView .dequeueReusableCellWithIdentifier("cell",
forIndexPath: indexPath)asUITableViewCell
cell.textLabel.text =String(format:"%i",
indexPath.row)
return cell
}
UIKit
// UILabel
func createLabel() ->UILabel {
,,,))
label.backgroundColor =UIColor.clearColor()
label.textAlignment =NSTextAlignment.Center
label.textColor =UIColor.blackColor()
label.)
label.text ="Hello Swift"
return label
}
// UIView
func createView() ->UIView {
var orginY =CGRectGetMaxY(self.myLabel.frame)
+
,
orginY,,))
myView.backgroundColor =UIColor.whiteColor()
return myView;
}
// UIButton
func createButton() ->UIButton {
var orginY =CGRectGetMaxY(self.myView.frame)
+
,
orginY,,))
button.backgroundColor =UIColor.greenColor()
button.setTitle("Button", forState:UIControlState.Normal)
button.)
button.addTarget(self, action:"tappedButton:", forControlEvents:UIControlEvents.TouchUpInside)
button.
return button
}
// UIImageView
func createImageView() ->UIImageView {
var orginY =CGRectGetMaxY(self.myButton.frame)
+
)/,
orginY,,))
var image:UIImage =UIImage(named:"user")
imageView.image = image
return imageView
}
// Button target
func tappedButton(sender:UIButton!) {
println(sender.tag)
}
push 控制器的方法
var listCtrl:UIViewController =UIViewController()
listCtrl.title ="View Controller"
listCtrl.view.backgroundColor =UIColor.redColor()
self.navigationController.pushViewController(listCtrl, animated:true)
pop
self.navigationController.popViewControllerAnimated(true)
使用Swift开发iOS项目、UI创建、方法调用的更多相关文章
- Swift开发iOS项目实战视频教程(一)---iOS真简单
本课主要介绍iOS项目的创建.第一个iOS项目的开发.UILabel.UIButton的使用. 假设你看完此视频还认为iOS非常难,请你来找我! 本教程摒弃枯燥的语法和知识解说,全是有趣有料的项目实战 ...
- Swift开发iOS项目实战视频教程(二)---图片与动画
本课主要介绍UIImageview.NSTimer的使用.并介绍了一种动画实现方式. 本教程摒弃枯燥的语法和知识解说.全是有趣有料的项目实战! 视频优酷链接:v.youku.com/v_show/id ...
- [Xcode 实际操作]一、博主领进门-(1)iOS项目的创建和项目模板的介绍
目录:[Swift]Xcode实际操作 本文将演示iOS项目的创建和项目模板的介绍. [Create a new Xcode project]创建一个新的项目. 在弹出的模板窗口中,显示了所有的项目模 ...
- [AIR] NativeExtension在IOS下的开发实例 --- IOS项目的创建 (一)
来源:http://bbs.9ria.com/thread-102037-1-1.html 最近看到本版块的很多关于NativeExtension的应用.但是都是在Android下面的应用.也有很多朋 ...
- Swift开发iOS应用过程中的问题和解决记录
虚拟机里安装OSX+XCode开发环境 用真机的请直接跳过这个部分. 主要是在VitrualBox里安装mac系统和xcode,参考这篇教程,VirtualBox的版本是4.3.18 r96156,O ...
- iOS项目常用效果方法注意点集锦
移动中隐藏tabBar,静止显示tabbar - (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView { // 隐藏tabbar ...
- swift开发新项目总结
新项目用swift3.0开发,现在基本一个月,来总结一下遇到的问题及解决方案 1,在确定新项目用swift后,第一个考虑的问题是用纯swift呢?还是用swift跟OC混编 考虑到新项目 ...
- Android开发笔记(5)——方法调用(基础)
转载请注明——博客园igoslly:http://www.cnblogs.com/igoslly/p/6833544.html 在实际方法调用中,程序按顺序逐句执行,直到“}”结束. 为避免程序大 ...
- 【VS开发】使用MFC创建并调用ActiveX控件
使用MFC创建并调用ActiveX控件 今天做了一下ActiveX的使用测试,总结一下: 首先使用MFC创建一个activeX的控件譬如ActiveXTest,编译成ocx并注册,然后另外编写一个测试 ...
随机推荐
- SqlHelper类-全面
// ===============================================================================// Microsoft Data ...
- HTML-在canvas画图中,图片的线上链接已配置允许跨域后,仍然出错提示跨域,怎么解决?
这个问题我已经遇到了2次,第一次解决了后,第二次又遇到了,所以这次做个笔记,怕以后再次遇到 举例: 1.要实现的问题:我需要在canvas画布上画上我的微信头像 2.后台配置已经完成了允许我头像地址的 ...
- Python内置函数和匿名函数
内容回顾: 1.列表推导式 [变量(加工后的变量) for 变量 in iterable] 循环模式 [变量(加工后的变量) for 变量 in iterable if 条件] 筛选模式 生成器表达式 ...
- extjs常用技巧
grid http://extjs.org.cn/node/590 监听 http://extjs.org.cn/node/593 总结 http://extjs.org.cn/node/641 常用 ...
- Oracle hidden costs revealed, Part2 – Using DTrace to find why writes in SYSTEM tablespace are slower than in others
http://blog.tanelpoder.com/2008/09/02/oracle-hidden-costs-revealed-part2-using-dtrace-to-find-why-wr ...
- CentOS 笔记
对安装CentOS安装使用过程中的问题做一个笔记,第一次安装,安装的是7.0版本,最小化安装. 安装环境 :Windows 2012 R2 Standard,Hyper-V Virstual Mach ...
- 邁向IT專家成功之路的三十則鐵律 鐵律二十三:IT人的成家之道-樸實
根據內政部一份2013年最新的調查報告指出台灣人的離婚率位居全球第三,想想看如果這是經濟成長率的排名表現那該有多好.然而究竟為何在台灣這塊小小的土地上,不僅離婚非常高而且晚婚的人也非常的多,其原因肯定 ...
- python(16)- python内置函数
python内置了一系列的常用函数,以便于我们使用,python英文官方文档详细说明:https://docs.python.org/3/library/functions.html Buil ...
- python(40)- 进程、线程、协程及IO模型
一.操作系统概念 操作系统位于底层硬件与应用软件之间的一层.工作方式:向下管理硬件,向上提供接口. 操作系统进行进程切换:1.出现IO操作:2.固定时间. 固定时间很短,人感受不到.每一个应用层运行起 ...
- STL之set具体解释(二)
首先来看看set集合容器: set集合容器实现了红黑树的平衡二叉树数据结构.在插入元素时它会自己主动调整二叉树的排列,把该元素放到适当的位置,而且 保证左右子树平衡.平衡二叉检索树採用中序遍历算法. ...