我的拖延症太嚴重,一直沒好好學習Swift。受@Allen_朝輝啓發,決定天天寫個小項目來學習Swift。git
項目代碼同步更新到github:項目地址github
1)簡單的計時器
2)使用 Timer.scheduledTimer
3)開始,暫停,重置功能swift
1)自定義字體
2)項目中導入字體文件(注意:直接拖到項目中,Build Phases - Copy Bundle Resources 肯沒有自動包含,須要手動添加)
3)在info.plist中添加Fonts provided by application屬性,添加字體
4)使用如下代碼打印出字體名字數組
for family in UIFont.familyNames { print("font-family:",family) for font in UIFont.fontNames(forFamilyName: family) { print("font-name:",font) } }
1)播放本地視頻
2)使用UITableView作個個視頻列表
3)import AVKit 使用AVPlayerViewController播放視頻app
1)模仿SnapChat樣式
2)左右兩個視圖是UIImageView
3)相機使用AVFoundation框架框架
1)UICollectionView實現的卡片選擇
2)使用UIBlurEffect UIVisualEffectView 添加了模糊效果dom
1)定位
2)在info.plist中添加 NSLocationWhenInUseUsageDescription
3)使用CoreLocation框架獲取當前位置ide
1)使用UIRefreshControl實現的下拉刷新學習
1)使用CAGradientLayer實現的隨機漸變背景色字體
CAGradientLayer的座標起點是左上角(0,0)終點是右下角(1,1) CAGradientLayer屬性: colors var colors: [AnyObject]? 一個包含CGColor的數組,規定全部的梯度所顯示的顏色,默認爲nil locations var locations: [NSNumber]? 一個內部是NSNumber的可選數組,規定全部的顏色梯度的區間範圍,選值只能在0到1之間,而且數組的數據必須單增,默認值爲nil endPoint var endPoint: CGPoint 終點座標 startPoint var startPoint: CGPoint 與endPoint相互對應,起點座標 type var type:String 繪製類型,默認值是axial,也就是線性繪製,各個顏色階層直接的變化是線性的
1)使用UIScrollView實現的圖片縮放功能
1)模仿spotyfi的登陸背景視頻播放
2)使用AVPlayer和AVPlayerLayer
1)漸變色TableView
2)根據行數計算顏色
let color = CGFloat(indexPath.row) / CGFloat(self.datas.count) * 0.8 cell.backgroundColor = UIColor.init(red: 0, green: color, blue: 1.0, alpha: 1.0)
1)登陸界面的小動畫2)進入頁面的動畫使用UIView.animate3)點擊登陸按鈕使用的CAKeyframeAnimation