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

 

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

 

iOS Swift基础知识代码

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

一、视图  +控件

1、UIImageView + UIImage

2、  UIView+UILabel

UIbutton

 

   //button
        let butt = UIButton(frame: CGRect(x: 150, y: 300, width: 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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值