自学 Swift - 三十天三十个 Swift 小项目(更新中...)

我的拖延症太严重,一直没好好学习Swift。受@Allen_朝辉启发,决定天天写个小项目来学习Swift。git

项目代码同步更新到github:项目地址github

Project 01 - SimpleStopWatch

clipboard.png

1)简单的计时器
2)使用 Timer.scheduledTimer
3)开始,暂停,重置功能swift

Project 02 - CustomFont

clipboard.png

1)自定义字体
2)项目中导入字体文件(注意:直接拖到项目中,Build Phases - Copy Bundle Resources 肯没有自动包含,须要手动添加)
3)在info.plist中添加Fonts provided by application属性,添加字体
clipboard.png
4)使用如下代码打印出字体名字数组

for family in UIFont.familyNames {
                    print("font-family:",family)
                    for font in UIFont.fontNames(forFamilyName: family) {
                        print("font-name:",font)
                    }
                }

Project 03 - PlayLocalVideo

clipboard.png

1)播放本地视频
2)使用UITableView作个个视频列表
3)import AVKit 使用AVPlayerViewController播放视频app

Project 04 - SnapChatMenu

clipboard.png

1)模仿SnapChat样式
2)左右两个视图是UIImageView
3)相机使用AVFoundation框架框架

Project 05 - CarouselEffect

clipboard.png

1)UICollectionView实现的卡片选择
2)使用UIBlurEffect UIVisualEffectView 添加了模糊效果dom

Project 06 - FindMyLocation

clipboard.png

1)定位
2)在info.plist中添加 NSLocationWhenInUseUsageDescription
3)使用CoreLocation框架获取当前位置ide

Project 07 - PullToRefresh

clipboard.png

1)使用UIRefreshControl实现的下拉刷新学习

Project 08 - RandomGradientColor

clipboard.png

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,也就是线性绘制,各个颜色阶层直接的变化是线性的

Project 09 -ImageScroller

clipboard.png

1)使用UIScrollView实现的图片缩放功能

Project 10 - VideoBackground

clipboard.png

1)模仿spotyfi的登陆背景视频播放
2)使用AVPlayer和AVPlayerLayer

Project 11 - GradientTableView

clipboard.png

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)

Project 12 - LoginAnimation

clipboard.png

1)登陆界面的小动画2)进入页面的动画使用UIView.animate3)点击登陆按钮使用的CAKeyframeAnimation

相关文章
相关标签/搜索