使用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并注册,然后另外编写一个测试 ...
随机推荐
- PHP的json_encode()函数的引号
PHP的json_encode()函数的引号 (1)数组的索引和值都使用双引号 $a = ["id"=>1,"age"=>12,"name ...
- yii执行流程
yii执行流程 原文:http://www.cnblogs.com/bluecobra/archive/2011/11/30/2269207.html 一 目录文件 |-framework 框 ...
- poj 1970(搜索)
The Game Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 6247 Accepted: 1601 Descript ...
- hdu 5455(字符串处理)
Fang Fang Time Limit: 1500/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)Total S ...
- LeetCode OJ--Regular Expression Matching
http://oj.leetcode.com/problems/regular-expression-matching/ 问题给想复杂了,只有p中可以含有. *,s中的字符都是确定的.想了好久,最终还 ...
- npm 查看模块全部版本
npm 查看模块全部版本:(jquery) npm view jquery versions 安装指定版本: (jquery) npm install jquery@1.7.2
- Codeforces635C XOR Equation【数学】
题目链接: http://codeforces.com/contest/635/problem/C 题意: 给定两个数的和s及异或x,求两个数的可能情况. 分析: 我们有公式a+b=a& b∗ ...
- ML | spectral clustering
What's xxx In multivariate statistics and the clustering of data, spectral clustering techniques mak ...
- wangzhi
http://blog.const.net.cn/a/9145.htm http://blog.sina.com.cn/s/blog_bf5abc95010169jf.html http://ciss ...
- c实现的trim函数
功能:去掉字符串首尾的空格,换行符等空白. 代码: #include <string.h> #include <stdio.h> #include <ctype.h> ...