//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创建、方法调用的更多相关文章

  1. Swift开发iOS项目实战视频教程(一)---iOS真简单

    本课主要介绍iOS项目的创建.第一个iOS项目的开发.UILabel.UIButton的使用. 假设你看完此视频还认为iOS非常难,请你来找我! 本教程摒弃枯燥的语法和知识解说,全是有趣有料的项目实战 ...

  2. Swift开发iOS项目实战视频教程(二)---图片与动画

    本课主要介绍UIImageview.NSTimer的使用.并介绍了一种动画实现方式. 本教程摒弃枯燥的语法和知识解说.全是有趣有料的项目实战! 视频优酷链接:v.youku.com/v_show/id ...

  3. [Xcode 实际操作]一、博主领进门-(1)iOS项目的创建和项目模板的介绍

    目录:[Swift]Xcode实际操作 本文将演示iOS项目的创建和项目模板的介绍. [Create a new Xcode project]创建一个新的项目. 在弹出的模板窗口中,显示了所有的项目模 ...

  4. [AIR] NativeExtension在IOS下的开发实例 --- IOS项目的创建 (一)

    来源:http://bbs.9ria.com/thread-102037-1-1.html 最近看到本版块的很多关于NativeExtension的应用.但是都是在Android下面的应用.也有很多朋 ...

  5. Swift开发iOS应用过程中的问题和解决记录

    虚拟机里安装OSX+XCode开发环境 用真机的请直接跳过这个部分. 主要是在VitrualBox里安装mac系统和xcode,参考这篇教程,VirtualBox的版本是4.3.18 r96156,O ...

  6. iOS项目常用效果方法注意点集锦

    移动中隐藏tabBar,静止显示tabbar - (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView { // 隐藏tabbar ...

  7. swift开发新项目总结

    新项目用swift3.0开发,现在基本一个月,来总结一下遇到的问题及解决方案   1,在确定新项目用swift后,第一个考虑的问题是用纯swift呢?还是用swift跟OC混编      考虑到新项目 ...

  8. Android开发笔记(5)——方法调用(基础)

    转载请注明——博客园igoslly:http://www.cnblogs.com/igoslly/p/6833544.html   在实际方法调用中,程序按顺序逐句执行,直到“}”结束. 为避免程序大 ...

  9. 【VS开发】使用MFC创建并调用ActiveX控件

    使用MFC创建并调用ActiveX控件 今天做了一下ActiveX的使用测试,总结一下: 首先使用MFC创建一个activeX的控件譬如ActiveXTest,编译成ocx并注册,然后另外编写一个测试 ...

随机推荐

  1. Linux 之 rsync实现服务器的文件同步

    rsync实现服务器的文件同步 参考文献链接: 一.rsync实现负载均衡集群文件同步,搭建线上测试部署环境 二.rsync. 三.rsync常见错误. 四.rsync 安装使用详解. 环境部署: 服 ...

  2. Ruby自动化测试(操作符的坑)

    事情是这样的: times++ @ddr = DDR::DDR.new() 执行到这里的时候,总是报错:'+@' undefied method.刚开始的时候以为是机器在重启过程中一些不稳定函数调用或 ...

  3. LeetCode OJ——Subsets

    http://oj.leetcode.com/problems/subsets/ 计算一个集合的子集,使用vector<vector<int> >,使用了进制的思想. #inc ...

  4. 我的js为什么会触发两次

    $(function() { $(".show").off("click").on("click",function(e){ e.preve ...

  5. T2821 天使之城 codevs

    http://codevs.cn/problem/2821/ 题目描述 Description 天使城有一个火车站,每辆火车都从A方向驶入车站,再从B方向驶出车站. 为了调度火车,火车站设有停放轨道, ...

  6. UVA 11090 Going in Cycle!! SPFA判断负环+二分

    原题链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem ...

  7. 基于python脚本的对拍debug

    首先,这是python脚本 import os; for i in range(0,20): print ("Case:"+str(i)); print ("random ...

  8. javascript 函数初探 (六)--- 闭包初探#3

    相关定义与闭包: 实际上,每个函数都可以被认为是一个闭包.因为每个函数都在其所在域(即该函数的作用域)中维护了某种联系. 但在大多数的时候,该作用于在函数体内被执行完之后就被自行销毁了.---除非发生 ...

  9. python numpy实现多次循环读取文件 等间隔过滤数据

    numpy的np.fromfile会出现如下的问题,只能一次性读取文件的内容,不能追加读取,连续两次的np.fromfile读到的东西一样 如果数据文件太大(几个G或以上)不能一次性全读进去,需要追加 ...

  10. [Algorithm] JavaScript Graph Data Structure

    A graph is a data structure comprised of a set of nodes, also known as vertices, and a set of edges. ...