使用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并注册,然后另外编写一个测试 ...
随机推荐
- AC日记——图灵机游戏 codevs 2292
2292 图灵机游戏 时间限制: 1 s 空间限制: 64000 KB 题目等级 : 黄金 Gold 题解 查看运行结果 题目描述 Description [Shadow 1]第二题 ...
- 牛客网 Wannafly挑战赛11 B.白兔的式子-组合数阶乘逆元快速幂
链接:https://www.nowcoder.com/acm/contest/73/B来源:牛客网 B.白兔的式子 时间限制:C/C++ 1秒,其他语言2秒空间限制:C/C++ 262144K, ...
- 通过XOML或者XAML的方式创建和启动工作流
在Workflow Foundation中,提供了多种设计工作流的方式.例如 纯代码的方式(C#) 代码分离的方式(XOML+C#) 以上两种,可以从Visual Studio提供的项目模板中选择 他 ...
- Light oj 1134 - Be Efficient (前缀和)
题目链接:http://www.lightoj.com/volume_showproblem.php?problem=1134 题意: 给你n个数,问你多少个连续的数的和是m的倍数. 思路: 前缀和取 ...
- 【ZJOI2017】树状数组
题目描述 漆黑的晚上,九条可怜躺在床上辗转反侧.难以入眠的她想起了若干年前她的一次悲惨的 OI 比赛经历.那是一道基础的树状数组题. 给出一个长度为 $n$ 的数组 $A$,初始值都为 $0$,接下来 ...
- numpy常用函数学习
目录numpy常用函数学习点乘法线型预测线性拟合裁剪.压缩和累乘相关性多项式拟合提取符号数组杂项点乘法该方法为数学方法,但是在numpy使用的时候略坑.numpy的点乘为a.dot(b)或numpy. ...
- iphone坐标系统
1,基本概念 CGPoint{x,y};空间中的位置,通过x和y坐标定义 CGSize{width, height}; 大小,通过宽度和高度定义 CGRect{origin, size};位置和大小, ...
- Android学习笔记(35):Android活动条
在Android3.0之后,Google对UI导航设计上进行了一系列的改革,当中有一个很好用的新功能就是引入的ActionBar,用于代替3.0之前的标题栏,并提供更为丰富的导航效果. ActionB ...
- 投影纹理映射(Projective Texture Mapping) 【转】
摘抄“GPU Programming And Cg Language Primer 1rd Edition” 中文名“GPU编程与CG语言之阳春白雪下里巴人” 投影纹理映射( Projective ...
- cocos2d-x-3.x bringToFront & sendToBack实现
void Node::bringToFront(void) { auto parent = this->getParent(); if (parent != nullptr && ...