使用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并注册,然后另外编写一个测试 ...
随机推荐
- linux命令——ll详解
一.ll命令 ll并不是linux下一个基本的命令,它实际上是ls -l的一个别名. Ubuntu默认不支持命令ll,必须用 ls -l,这样使用起来不是很方便. 如果要使用此命令,可以作如下修改:打 ...
- js-禁止微信内置浏览器调整字体大小
js方法: (function(){ if(typeof WeixinJSBridge=="object"&& typeof WeixinJSBridge ...
- 浅谈DPCHookSSDT和RemoveDPC
最近学了DPC这一对,把Win7 32位和64位都做了,查阅了大量的资料,并且进行了大量调试,理一下思路,为了后面更好的学习. 转载请注明出处:http://www.cnblogs.com/littl ...
- 使用KNN对iris数据集进行分类——python
filename='g:\data\iris.csv' lines=fr.readlines()Mat=zeros((len(lines),4))irisLabels=[]index=0for lin ...
- OceanBase分区表有什么不同?
概述 分区表是ORACLE从8.0开始引入的功能,也是第一个支持物理分区的数据库,随后其他数据库纷纷跟进.分区表是一种“分而治之”的思想,通过将大表.索引分成可以独立管理的.小的片段(Segment) ...
- [开源] FreeSql.Tools Razor 生成器
FreeSql 经过半年的开发和坚持维护,在 0.6.x 版本中完成了几大重要事件: 1.按小包拆分,每个数据库实现为单独 dll: 2.实现 .net framework 4.5 支持: 3.同时支 ...
- HTTPS协议工作流程
被问到了,复习一下HTTPS的工作流程 提到https,不得不提SSL SSL 1. 安全套接字(Secure Socket Layer,SSL)协议是Web浏览器与Web服务器之间安全 ...
- Android自定义xml解析
<?xml version="1.0" encoding="utf-8"?> <resources> <Users> < ...
- Android--绑定服务调用服务的方法
Service依照其启动的方式,可分为两种: 1.Started Started的Service.通过在Application里用startService(Intent intent)方法来启动.这样 ...
- javascript 转义函数
// 字符转义 html2Escape(sHtml) { return sHtml.replace(/[<>&"]/g, function(c) { return { ' ...