iOS Swift 模块练习/swift基础学习

SWIFT项目练习1      SWIFT项目练习2 

iOS Swift基础知识代码

推荐:Swift学习使用知识代码软件

 

0.swift中的宏定义(使用方法代替宏)

一、视图  +控件

1、UIImageView + UIImage

2、  UIView+UILabel

UIbutton

   //button
        let butt = UIButton(frame: CGRect(x: 150, y: 300,  100, height: 30))
        butt.setTitle("tiaozhuan", for: .normal)
        butt.layer.cornerRadius = 5
        butt.addTarget(self, action:#selector(buttonaction(sender:)), for: .touchUpInside)
        self.view.addSubview(butt)
        
        
    }
    
    //button 事件
    func buttonaction(sender:UIButton)  {
        
        
        self.present(buttonViewController(), animated: true, completion: nil)
    }

 3、Swift UITableView 

4、Swift3.0 UITextField

 5/Swift tableview自带的刷新控件

二、代码设计:继承扩展封装

1swift实现单例的四种方式

 2、实例方法和类型方法

 三、三方使用

1、Cocoapods 使用  与OC大致一样,只有在podfile 开始的注释中有一点更改

Swift使用时:

注意:你不能使用TextEdit来编辑Podfile,因为它有可能用图形化的更有吸引力的typeset quotes代替standard quotes,这可能导致CocoaPods不能理解并抛出错误,所以最好用Xcode或者别的编程文本编辑器来编辑你的Podfile。

默认的podFile看起来是这样的:


# Uncomment this line to define a global platform for your project# platform :ios, '6.0' 
target 'IceCreamShop' do 
end 
target 'IceCreamShopTests' do 
end
将注释的内容替换成下面的两行:

1
platform :ios, "8.0"use_frameworks!
这就告诉了CocoaPods--你的项目使用的是iOS 8.0,并且将使用框架来代替静态库。

想要在Swift中使用CocoaPods,你必须明确的写出use_frameworks! 来选择使用框架。如果你忘了写这个,CocoaPods能检测到你使用使用Swift CocoaPods,你安装pods的时候就会报错。
原文地址:https://www.cnblogs.com/xujiahui/p/6928210.html