Repository: Fnoz/FNMatchPull
Branch: master
Commit: ab3826d6547f
Files: 27
Total size: 92.9 KB
Directory structure:
gitextract_awijepqm/
├── .swift-version
├── FNMatchPull/
│ ├── AppDelegate.swift
│ ├── Assets.xcassets/
│ │ ├── AppIcon.appiconset/
│ │ │ └── Contents.json
│ │ ├── Contents.json
│ │ └── Image/
│ │ ├── Contents.json
│ │ ├── icn_0.imageset/
│ │ │ └── Contents.json
│ │ ├── icn_1.imageset/
│ │ │ └── Contents.json
│ │ └── icn_2.imageset/
│ │ └── Contents.json
│ ├── Base.lproj/
│ │ ├── LaunchScreen.storyboard
│ │ └── Main.storyboard
│ ├── FNMatchPull/
│ │ ├── FNAnimator.swift
│ │ ├── FNMatchFontParser.swift
│ │ ├── FNMatchPullAnimator.swift
│ │ ├── FNMatchPullMatch.swift
│ │ ├── FNMatchPullView.swift
│ │ ├── FNPullToRefreshExtension.swift
│ │ └── FNPullToRefreshView.swift
│ ├── FNMatchPullTableViewCell.swift
│ ├── Info.plist
│ └── ViewController.swift
├── FNMatchPull.podspec
├── FNMatchPull.xcodeproj/
│ ├── project.pbxproj
│ ├── project.xcworkspace/
│ │ └── contents.xcworkspacedata
│ └── xcuserdata/
│ └── Fnoz.xcuserdatad/
│ └── xcschemes/
│ └── FNMatchPull.xcscheme
├── LICENSE
├── README.md
└── README.zh-CN.md
================================================
FILE CONTENTS
================================================
================================================
FILE: .swift-version
================================================
3.0
================================================
FILE: FNMatchPull/AppDelegate.swift
================================================
//
// AppDelegate.swift
// FNMatchPull
//
// Created by Fnoz on 16/6/26.
// Copyright © 2016年 Fnoz. All rights reserved.
//
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}
func applicationWillResignActive(_ application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}
func applicationDidEnterBackground(_ application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
func applicationWillEnterForeground(_ application: UIApplication) {
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}
func applicationDidBecomeActive(_ application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
func applicationWillTerminate(_ application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
}
================================================
FILE: FNMatchPull/Assets.xcassets/AppIcon.appiconset/Contents.json
================================================
{
"images" : [
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
================================================
FILE: FNMatchPull/Assets.xcassets/Contents.json
================================================
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}
================================================
FILE: FNMatchPull/Assets.xcassets/Image/Contents.json
================================================
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}
================================================
FILE: FNMatchPull/Assets.xcassets/Image/icn_0.imageset/Contents.json
================================================
{
"images" : [
{
"idiom" : "universal",
"filename" : "icn_3.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "icn_3@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "icn_3@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
================================================
FILE: FNMatchPull/Assets.xcassets/Image/icn_1.imageset/Contents.json
================================================
{
"images" : [
{
"idiom" : "universal",
"filename" : "icn_1.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "icn_1@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "icn_1@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
================================================
FILE: FNMatchPull/Assets.xcassets/Image/icn_2.imageset/Contents.json
================================================
{
"images" : [
{
"idiom" : "universal",
"filename" : "icn_2.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "icn_2@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "icn_2@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
================================================
FILE: FNMatchPull/Base.lproj/LaunchScreen.storyboard
================================================
================================================
FILE: FNMatchPull/Base.lproj/Main.storyboard
================================================
================================================
FILE: FNMatchPull/FNMatchPull/FNAnimator.swift
================================================
//
// Animator.swift
//
// Copyright (c) 2014 Josip Cavar
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
import Foundation
import QuartzCore
import UIKit
internal class FNAnimatorView: UIView {
fileprivate let titleLabel: UILabel = {
let label = UILabel()
label.translatesAutoresizingMaskIntoConstraints = false
return label
}()
fileprivate let activityIndicatorView: UIActivityIndicatorView = {
let activity = UIActivityIndicatorView(activityIndicatorStyle: .gray)
activity.translatesAutoresizingMaskIntoConstraints = false
return activity
}()
override init(frame: CGRect) {
super.init(frame: frame)
autoresizingMask = [UIViewAutoresizing.flexibleWidth, UIViewAutoresizing.flexibleHeight]
addSubview(titleLabel)
addSubview(activityIndicatorView)
let leftActivityConstraint = NSLayoutConstraint(item: activityIndicatorView, attribute: .left, relatedBy: .equal, toItem: self, attribute: .left, multiplier: 1, constant: 16)
let centerActivityConstraint = NSLayoutConstraint(item: activityIndicatorView, attribute: .centerY, relatedBy: .equal, toItem: self, attribute: .centerY, multiplier: 1, constant: 0)
let leftTitleConstraint = NSLayoutConstraint(item: titleLabel, attribute: .left, relatedBy: .equal, toItem: activityIndicatorView, attribute: .right, multiplier: 1, constant: 16)
let centerTitleConstraint = NSLayoutConstraint(item: self, attribute: .centerY, relatedBy: .equal, toItem: titleLabel, attribute: .centerY, multiplier: 1, constant: 0)
addConstraints([leftActivityConstraint, centerActivityConstraint, leftTitleConstraint, centerTitleConstraint])
}
required init(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
class FNAnimator: FNPullToRefreshViewDelegate {
internal let animatorView: FNAnimatorView
init(frame: CGRect) {
animatorView = FNAnimatorView(frame: frame)
}
func pullToRefreshAnimationDidStart(_ view: FNPullToRefreshView) {
animatorView.activityIndicatorView.startAnimating()
animatorView.titleLabel.text = "Loading"
}
func pullToRefreshAnimationDidEnd(_ view: FNPullToRefreshView) {
animatorView.activityIndicatorView.stopAnimating()
animatorView.titleLabel.text = ""
}
func pullToRefresh(_ view: FNPullToRefreshView, progressDidChange progress: CGFloat) {
}
func pullToRefresh(_ view: FNPullToRefreshView, stateDidChange state: FNPullToRefreshViewState) {
switch state {
case .loading:
animatorView.titleLabel.text = "Loading"
case .pullToRefresh:
animatorView.titleLabel.text = "Pull to refresh"
case .releaseToRefresh:
animatorView.titleLabel.text = "Release to refresh"
}
}
}
================================================
FILE: FNMatchPull/FNMatchPull/FNMatchFontParser.swift
================================================
//
// FNMatchFontParser.swift
// FNMatchPull
//
// Created by Fnoz on 16/6/26.
// Copyright © 2016年 Fnoz. All rights reserved.
//
import Foundation
import UIKit
let fontWidth = CGFloat(25.0)
let fontHeight = CGFloat(25.0)
let fontWidthWithMargin = CGFloat(35.0)
class FNMatchFontParser: NSObject {
class func parserText(_ text: NSString, width: CGFloat) -> (NSArray, NSArray) {
let startPoints: NSMutableArray = []
let endPoints: NSMutableArray = []
let leftMargin = (width - fontWidthWithMargin * CGFloat(text.length) + fontWidthWithMargin - fontWidth)/2
let topMargin = (pullViewHeight - fontHeight)/2
for i in 0 ... text.length - 1 {
let char = text.substring(with: NSMakeRange(i, 1))
let (startPointsToAdd, endPointsToAdd) = parserChar(char as NSString)
if startPointsToAdd.count == 0 || endPointsToAdd.count == 0 {
continue
}
for j in 0 ... startPointsToAdd.count - 1 {
var startPoint = (startPointsToAdd[j] as! NSValue).cgPointValue
startPoint.x += leftMargin + CGFloat(i) * fontWidthWithMargin
startPoint.y += topMargin
startPointsToAdd.replaceObject(at: j, with: NSValue.init(cgPoint: startPoint))
var endPoint = (endPointsToAdd[j] as! NSValue).cgPointValue
endPoint.x += leftMargin + CGFloat(i) * fontWidthWithMargin
endPoint.y += topMargin
endPointsToAdd.replaceObject(at: j, with: NSValue.init(cgPoint: endPoint))
}
startPoints.addObjects(from: startPointsToAdd as [AnyObject])
endPoints.addObjects(from: endPointsToAdd as [AnyObject])
}
return (startPoints, endPoints)
}
class func parserChar(_ char: NSString) -> (NSMutableArray, NSMutableArray) {
var startPointsToAdd:NSMutableArray = []
var endPointsToAdd:NSMutableArray = []
switch char {
case "A","a":
startPointsToAdd = [NSValue.init(cgPoint: CGPoint(x: fontWidth * 0.5, y: 0)),
NSValue.init(cgPoint: CGPoint(x: 0, y: fontHeight * 0.3)),
NSValue.init(cgPoint: CGPoint(x: 0, y: fontHeight * 0.6)),
NSValue.init(cgPoint: CGPoint(x: fontWidth * 0.5, y: 0)),
NSValue.init(cgPoint: CGPoint(x: 0, y: fontHeight * 0.6)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: fontHeight * 0.3)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: fontHeight * 0.6))]
endPointsToAdd = [NSValue.init(cgPoint: CGPoint(x: 0, y: fontHeight * 0.3)),
NSValue.init(cgPoint: CGPoint(x: 0, y: fontHeight * 0.6)),
NSValue.init(cgPoint: CGPoint(x: 0, y: fontHeight)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: fontHeight * 0.3)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: fontHeight * 0.6)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: fontHeight * 0.6)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: fontHeight))]
break
case "B","b":
startPointsToAdd = [NSValue.init(cgPoint: CGPoint(x: 0, y: 0)),
NSValue.init(cgPoint: CGPoint(x: 0, y: 0)),
NSValue.init(cgPoint: CGPoint(x: fontHeight * 0.55, y: 0)),
NSValue.init(cgPoint: CGPoint(x: 0, y: fontHeight * 0.45)),
NSValue.init(cgPoint: CGPoint(x: 0, y: fontHeight * 0.45)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: fontHeight * 0.45)),
NSValue.init(cgPoint: CGPoint(x: 0, y: fontHeight))]
endPointsToAdd = [NSValue.init(cgPoint: CGPoint(x: 0, y: fontHeight * 0.45)),
NSValue.init(cgPoint: CGPoint(x: fontHeight * 0.55, y: 0)),
NSValue.init(cgPoint: CGPoint(x: fontHeight * 0.45, y: fontHeight * 0.45)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: fontHeight * 0.45)),
NSValue.init(cgPoint: CGPoint(x: 0, y: fontHeight)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: fontHeight)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: fontHeight))]
break
case "C","c":
startPointsToAdd = [NSValue.init(cgPoint: CGPoint(x: 0, y: 0)),
NSValue.init(cgPoint: CGPoint(x: 0, y: 0)),
NSValue.init(cgPoint: CGPoint(x: 0, y: fontHeight * 0.5)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: 0)),
NSValue.init(cgPoint: CGPoint(x: 0, y: fontHeight)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: fontHeight * 0.7))]
endPointsToAdd = [NSValue.init(cgPoint: CGPoint(x: 0, y: fontHeight * 0.5)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: 0)),
NSValue.init(cgPoint: CGPoint(x: 0, y: fontHeight)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: fontHeight * 0.3)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: fontHeight)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: fontHeight))]
break
case "D","d":
startPointsToAdd = [NSValue.init(cgPoint: CGPoint(x: fontWidth * 0.2, y: 0)),
NSValue.init(cgPoint: CGPoint(x: fontWidth * 0.2, y: fontHeight * 0.5)),
NSValue.init(cgPoint: CGPoint(x: 0, y: 0)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: 0)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: fontHeight * 0.5)),
NSValue.init(cgPoint: CGPoint(x: 0, y: fontHeight))]
endPointsToAdd = [NSValue.init(cgPoint: CGPoint(x: fontWidth * 0.2, y: fontHeight * 0.5)),
NSValue.init(cgPoint: CGPoint(x: fontWidth * 0.2, y: fontHeight)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: 0)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: fontHeight * 0.5)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: fontHeight)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: fontHeight))]
break
case "E","e":
startPointsToAdd = [NSValue.init(cgPoint: CGPoint(x: 0, y: 0)),
NSValue.init(cgPoint: CGPoint(x: 0, y: 0)),
NSValue.init(cgPoint: CGPoint(x: 0, y: fontHeight * 0.5)),
NSValue.init(cgPoint: CGPoint(x: 0, y: fontHeight * 0.5)),
NSValue.init(cgPoint: CGPoint(x: 0, y: fontHeight))]
endPointsToAdd = [NSValue.init(cgPoint: CGPoint(x: 0, y: fontHeight * 0.5)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: 0)),
NSValue.init(cgPoint: CGPoint(x: 0, y: fontHeight)),
NSValue.init(cgPoint: CGPoint(x: fontWidth * 0.8, y: fontHeight * 0.5)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: fontHeight))]
break
case "F","f":
startPointsToAdd = [NSValue.init(cgPoint: CGPoint(x: 0, y: 0)),
NSValue.init(cgPoint: CGPoint(x: 0, y: 0)),
NSValue.init(cgPoint: CGPoint(x: 0, y: fontHeight * 0.5)),
NSValue.init(cgPoint: CGPoint(x: 0, y: fontHeight * 0.5))]
endPointsToAdd = [NSValue.init(cgPoint: CGPoint(x: 0, y: fontHeight * 0.5)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: 0)),
NSValue.init(cgPoint: CGPoint(x: 0, y: fontHeight)),
NSValue.init(cgPoint: CGPoint(x: fontWidth * 0.8, y: fontHeight * 0.5))]
break
case "G","g":
startPointsToAdd = [NSValue.init(cgPoint: CGPoint(x: 0, y: 0)),
NSValue.init(cgPoint: CGPoint(x: 0, y: 0)),
NSValue.init(cgPoint: CGPoint(x: 0, y: fontHeight * 0.5)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: 0)),
NSValue.init(cgPoint: CGPoint(x: fontWidth * 0.5, y: fontHeight * 0.5)),
NSValue.init(cgPoint: CGPoint(x: 0, y: fontHeight)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: fontHeight * 0.5))]
endPointsToAdd = [NSValue.init(cgPoint: CGPoint(x: 0, y: fontHeight * 0.5)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: 0)),
NSValue.init(cgPoint: CGPoint(x: 0, y: fontHeight)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: fontHeight * 0.3)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: fontHeight * 0.5)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: fontHeight)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: fontHeight))]
break
case "H","h":
startPointsToAdd = [NSValue.init(cgPoint: CGPoint(x: 0, y: 0)),
NSValue.init(cgPoint: CGPoint(x: 0, y: fontHeight * 0.5)),
NSValue.init(cgPoint: CGPoint(x: 0, y: fontHeight * 0.5)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: 0)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: fontHeight * 0.5))]
endPointsToAdd = [NSValue.init(cgPoint: CGPoint(x: 0, y: fontHeight * 0.5)),
NSValue.init(cgPoint: CGPoint(x: 0, y: fontHeight)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: fontHeight * 0.5)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: fontHeight * 0.5)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: fontHeight))]
break
case "I","i":
startPointsToAdd = [NSValue.init(cgPoint: CGPoint(x: fontWidth * 0.5, y: 0)),
NSValue.init(cgPoint: CGPoint(x: fontWidth * 0.5, y: fontHeight * 0.5))]
endPointsToAdd = [NSValue.init(cgPoint: CGPoint(x: fontWidth * 0.5, y: fontHeight * 0.5)),
NSValue.init(cgPoint: CGPoint(x: fontWidth * 0.5, y: fontHeight))]
break
case "J","j":
startPointsToAdd = [NSValue.init(cgPoint: CGPoint(x: fontWidth * 0.9, y: 0)),
NSValue.init(cgPoint: CGPoint(x: fontWidth * 0.9, y: fontHeight * 0.5)),
NSValue.init(cgPoint: CGPoint(x: fontWidth * 0.1, y: fontHeight * 0.8)),
NSValue.init(cgPoint: CGPoint(x: fontWidth * 0.1, y: fontHeight))]
endPointsToAdd = [NSValue.init(cgPoint: CGPoint(x: fontWidth * 0.9, y: fontHeight * 0.5)),
NSValue.init(cgPoint: CGPoint(x: fontWidth * 0.9, y: fontHeight)),
NSValue.init(cgPoint: CGPoint(x: fontWidth * 0.1, y: fontHeight)),
NSValue.init(cgPoint: CGPoint(x: fontWidth * 0.9, y: fontHeight))]
break
case "K","k":
startPointsToAdd = [NSValue.init(cgPoint: CGPoint(x: 0, y: 0)),
NSValue.init(cgPoint: CGPoint(x: 0, y: fontHeight * 0.5)),
NSValue.init(cgPoint: CGPoint(x: 0, y: fontHeight * 0.5)),
NSValue.init(cgPoint: CGPoint(x: fontWidth * 0.7, y: fontHeight * 0.5)),
NSValue.init(cgPoint: CGPoint(x: fontWidth * 0.7, y: fontHeight * 0.5))]
endPointsToAdd = [NSValue.init(cgPoint: CGPoint(x: 0, y: fontHeight * 0.5)),
NSValue.init(cgPoint: CGPoint(x: 0, y: fontHeight)),
NSValue.init(cgPoint: CGPoint(x: fontWidth * 0.7, y: fontHeight * 0.5)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: 0)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: fontHeight))]
break
case "L","l":
startPointsToAdd = [NSValue.init(cgPoint: CGPoint(x: fontWidth * 0.1, y: 0)),
NSValue.init(cgPoint: CGPoint(x: fontWidth * 0.1, y: fontHeight * 0.5)),
NSValue.init(cgPoint: CGPoint(x: fontWidth * 0.1, y: fontHeight))]
endPointsToAdd = [NSValue.init(cgPoint: CGPoint(x: fontWidth * 0.1, y: fontHeight * 0.5)),
NSValue.init(cgPoint: CGPoint(x: fontWidth * 0.1, y: fontHeight)),
NSValue.init(cgPoint: CGPoint(x: fontWidth * 0.9, y: fontHeight))]
break
case "M","m":
startPointsToAdd = [NSValue.init(cgPoint: CGPoint(x: 0, y: 0)),
NSValue.init(cgPoint: CGPoint(x: 0, y: fontHeight * 0.5)),
NSValue.init(cgPoint: CGPoint(x: 0, y: 0)),
NSValue.init(cgPoint: CGPoint(x: fontWidth * 0.5, y: fontHeight * 0.4)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: 0)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: fontHeight * 0.5))]
endPointsToAdd = [NSValue.init(cgPoint: CGPoint(x: 0, y: fontHeight * 0.5)),
NSValue.init(cgPoint: CGPoint(x: 0, y: fontHeight)),
NSValue.init(cgPoint: CGPoint(x: fontWidth * 0.5, y: fontHeight * 0.4)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: 0)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: fontHeight * 0.5)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: fontHeight))]
break
case "N","n":
startPointsToAdd = [NSValue.init(cgPoint: CGPoint(x: 0, y: 0)),
NSValue.init(cgPoint: CGPoint(x: 0, y: fontHeight * 0.5)),
NSValue.init(cgPoint: CGPoint(x: 0, y: 0)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: 0)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: fontHeight * 0.5))]
endPointsToAdd = [NSValue.init(cgPoint: CGPoint(x: 0, y: fontHeight * 0.5)),
NSValue.init(cgPoint: CGPoint(x: 0, y: fontHeight)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: fontHeight * 0.6)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: fontHeight * 0.5)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: fontHeight))]
break
case "O","o":
startPointsToAdd = [NSValue.init(cgPoint: CGPoint(x: 0, y: 0)),
NSValue.init(cgPoint: CGPoint(x: 0, y: fontHeight * 0.5)),
NSValue.init(cgPoint: CGPoint(x: 0, y: 0)),
NSValue.init(cgPoint: CGPoint(x: 0, y: fontHeight)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: 0)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: fontHeight * 0.5))]
endPointsToAdd = [NSValue.init(cgPoint: CGPoint(x: 0, y: fontHeight * 0.5)),
NSValue.init(cgPoint: CGPoint(x: 0, y: fontHeight)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: 0)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: fontHeight)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: fontHeight * 0.5)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: fontHeight))]
break
case "P","p":
startPointsToAdd = [NSValue.init(cgPoint: CGPoint(x: 0, y: 0)),
NSValue.init(cgPoint: CGPoint(x: 0, y: fontHeight * 0.6)),
NSValue.init(cgPoint: CGPoint(x: 0, y: 0)),
NSValue.init(cgPoint: CGPoint(x: 0, y: fontHeight * 0.6)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: 0))]
endPointsToAdd = [NSValue.init(cgPoint: CGPoint(x: 0, y: fontHeight * 0.6)),
NSValue.init(cgPoint: CGPoint(x: 0, y: fontHeight)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: 0)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: fontHeight * 0.6)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: fontHeight * 0.6))]
break
case "Q","q":
startPointsToAdd = [NSValue.init(cgPoint: CGPoint(x: 0, y: 0)),
NSValue.init(cgPoint: CGPoint(x: 0, y: fontHeight * 0.5)),
NSValue.init(cgPoint: CGPoint(x: 0, y: 0)),
NSValue.init(cgPoint: CGPoint(x: 0, y: fontHeight)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: 0)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: fontHeight * 0.5)),
NSValue.init(cgPoint: CGPoint(x: fontWidth * 0.4, y: fontHeight * 0.75))]
endPointsToAdd = [NSValue.init(cgPoint: CGPoint(x: 0, y: fontHeight * 0.5)),
NSValue.init(cgPoint: CGPoint(x: 0, y: fontHeight)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: 0)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: fontHeight)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: fontHeight * 0.5)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: fontHeight)),
NSValue.init(cgPoint: CGPoint(x: fontWidth * 0.6, y: fontHeight * 1.25))]
break
case "R","r":
startPointsToAdd = [NSValue.init(cgPoint: CGPoint(x: 0, y: 0)),
NSValue.init(cgPoint: CGPoint(x: 0, y: fontHeight * 0.6)),
NSValue.init(cgPoint: CGPoint(x: 0, y: 0)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: 0)),
NSValue.init(cgPoint: CGPoint(x: 0, y: fontHeight * 0.6)),
NSValue.init(cgPoint: CGPoint(x: fontWidth * 0.6, y: fontHeight * 0.6))]
endPointsToAdd = [NSValue.init(cgPoint: CGPoint(x: 0, y: fontHeight * 0.6)),
NSValue.init(cgPoint: CGPoint(x: 0, y: fontHeight)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: 0)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: fontHeight * 0.6)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: fontHeight * 0.6)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: fontHeight))]
break
case "S","s":
startPointsToAdd = [NSValue.init(cgPoint: CGPoint(x: 0, y: 0)),
NSValue.init(cgPoint: CGPoint(x: 0, y: 0)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: 0)),
NSValue.init(cgPoint: CGPoint(x: 0, y: fontHeight * 0.45)),
NSValue.init(cgPoint: CGPoint(x: 0, y: fontHeight * 0.8)),
NSValue.init(cgPoint: CGPoint(x: 0, y: fontHeight)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: fontHeight * 0.45))]
endPointsToAdd = [NSValue.init(cgPoint: CGPoint(x: 0, y: fontHeight * 0.45)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: 0)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: fontHeight * 0.2)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: fontHeight * 0.45)),
NSValue.init(cgPoint: CGPoint(x: 0, y: fontHeight)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: fontHeight)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: fontHeight))]
break
case "T","t":
startPointsToAdd = [NSValue.init(cgPoint: CGPoint(x: 0, y: 0)),
NSValue.init(cgPoint: CGPoint(x: fontWidth * 0.5, y: 0)),
NSValue.init(cgPoint: CGPoint(x: fontWidth * 0.5, y: fontHeight * 0.5))]
endPointsToAdd = [NSValue.init(cgPoint: CGPoint(x: fontWidth, y: 0)),
NSValue.init(cgPoint: CGPoint(x: fontWidth * 0.5, y: fontHeight * 0.5)),
NSValue.init(cgPoint: CGPoint(x: fontWidth * 0.5, y: fontHeight))]
break
case "U","u":
startPointsToAdd = [NSValue.init(cgPoint: CGPoint(x: 0, y: 0)),
NSValue.init(cgPoint: CGPoint(x: 0, y: fontHeight * 0.5)),
NSValue.init(cgPoint: CGPoint(x: 0, y: fontHeight)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: 0)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: fontHeight * 0.5))]
endPointsToAdd = [NSValue.init(cgPoint: CGPoint(x: 0, y: fontHeight * 0.5)),
NSValue.init(cgPoint: CGPoint(x: 0, y: fontHeight)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: fontHeight)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: fontHeight * 0.5)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: fontHeight))]
break
case "V","v":
startPointsToAdd = [NSValue.init(cgPoint: CGPoint(x: 0, y: 0)),
NSValue.init(cgPoint: CGPoint(x: fontWidth * 0.25, y: fontHeight * 0.5)),
NSValue.init(cgPoint: CGPoint(x: fontWidth * 0.5, y: fontHeight)),
NSValue.init(cgPoint: CGPoint(x: fontWidth * 0.75, y: fontHeight * 0.5))]
endPointsToAdd = [NSValue.init(cgPoint: CGPoint(x: fontWidth * 0.25, y: fontHeight * 0.5)),
NSValue.init(cgPoint: CGPoint(x: fontWidth * 0.5, y: fontHeight)),
NSValue.init(cgPoint: CGPoint(x: fontWidth * 0.75, y: fontHeight * 0.5)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: 0))]
break
case "W","w":
startPointsToAdd = [NSValue.init(cgPoint: CGPoint(x: fontWidth * -0.1, y: 0)),
NSValue.init(cgPoint: CGPoint(x: fontWidth * -0.05, y: fontHeight * 0.5)),
NSValue.init(cgPoint: CGPoint(x: fontWidth * 0.5, y: fontHeight * 0.3)),
NSValue.init(cgPoint: CGPoint(x: 0, y: fontHeight)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: fontHeight)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: fontHeight)),
NSValue.init(cgPoint: CGPoint(x: fontWidth * 1.05, y: fontHeight * 0.5))]
endPointsToAdd = [NSValue.init(cgPoint: CGPoint(x: fontWidth * -0.05, y: fontHeight * 0.5)),
NSValue.init(cgPoint: CGPoint(x: 0, y: fontHeight)),
NSValue.init(cgPoint: CGPoint(x: fontWidth * 0.5, y: fontHeight)),
NSValue.init(cgPoint: CGPoint(x: fontWidth * 0.5, y: fontHeight)),
NSValue.init(cgPoint: CGPoint(x: fontWidth * 0.5, y: fontHeight)),
NSValue.init(cgPoint: CGPoint(x: fontWidth * 1.05, y: fontHeight * 0.5)),
NSValue.init(cgPoint: CGPoint(x: fontWidth * 1.1, y: 0))]
break
case "X","x":
startPointsToAdd = [NSValue.init(cgPoint: CGPoint(x: 0, y: 0)),
NSValue.init(cgPoint: CGPoint(x: 0, y: fontHeight)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: 0)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: fontHeight))]
endPointsToAdd = [NSValue.init(cgPoint: CGPoint(x: fontWidth * 0.5, y: fontHeight * 0.5)),
NSValue.init(cgPoint: CGPoint(x: fontWidth * 0.5, y: fontHeight * 0.5)),
NSValue.init(cgPoint: CGPoint(x: fontWidth * 0.5, y: fontHeight * 0.5)),
NSValue.init(cgPoint: CGPoint(x: fontWidth * 0.5, y: fontHeight * 0.5))]
break
case "Y","y":
startPointsToAdd = [NSValue.init(cgPoint: CGPoint(x: 0, y: 0)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: 0)),
NSValue.init(cgPoint: CGPoint(x: 0, y: fontHeight * 0.6)),
NSValue.init(cgPoint: CGPoint(x: fontWidth * 0.5, y: fontHeight * 0.6))]
endPointsToAdd = [NSValue.init(cgPoint: CGPoint(x: 0, y: fontHeight * 0.6)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: fontHeight * 0.6)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: fontHeight * 0.6)),
NSValue.init(cgPoint: CGPoint(x: fontWidth * 0.5, y: fontHeight))]
break
case "Z","z":
startPointsToAdd = [NSValue.init(cgPoint: CGPoint(x: 0, y: 0)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: 0)),
NSValue.init(cgPoint: CGPoint(x: fontWidth * 0.5, y: fontHeight * 0.5)),
NSValue.init(cgPoint: CGPoint(x: 0, y: fontHeight))]
endPointsToAdd = [NSValue.init(cgPoint: CGPoint(x: fontWidth, y: 0)),
NSValue.init(cgPoint: CGPoint(x: fontWidth * 0.5, y: fontHeight * 0.5)),
NSValue.init(cgPoint: CGPoint(x: 0, y: fontHeight)),
NSValue.init(cgPoint: CGPoint(x: fontWidth, y: fontHeight))]
break
case ",":
startPointsToAdd = [NSValue.init(cgPoint: CGPoint(x: fontWidth * 0.35, y: fontHeight * 0.65))]
endPointsToAdd = [NSValue.init(cgPoint: CGPoint(x: fontWidth * 0.35, y: fontHeight))]
break
default:
break
}
return (startPointsToAdd, endPointsToAdd)
}
}
================================================
FILE: FNMatchPull/FNMatchPull/FNMatchPullAnimator.swift
================================================
//
// FNMatchPullAnimator.swift
// FNMatchPull
//
// Created by Fnoz on 16/6/25.
// Copyright © 2016年 Fnoz. All rights reserved.
//
import UIKit
// Pull down style, support text and pattern
public enum FNMatchPullStyle: NSInteger {
case pattern = 0
case text = 1
}
public class FNMatchPullAnimator: UIView, FNPullToRefreshViewDelegate {
var matchPullView: FNMatchPullView!
// Pull down style
public var style: FNMatchPullStyle! {
didSet {
matchPullView.style = style
matchPullView.initMatch()
}
}
// Text charaters, supports English letters and comma.
public var text: NSString! {
didSet {
matchPullView.text = text
matchPullView.initMatch()
}
}
public var lineWidth:CGFloat? {
didSet {
matchPullView.lineWidth = lineWidth
matchPullView.initMatch()
}
}
public var startPoints:NSArray? {
didSet {
matchPullView.startPoints = startPoints!
matchPullView.initMatch()
}
}
public var endPoints:NSArray? {
didSet {
matchPullView.endPoints = endPoints!
matchPullView.initMatch()
}
}
fileprivate let layerLoader = CAShapeLayer()
fileprivate let layerSeparator = CAShapeLayer()
public override init(frame: CGRect) {
super.init(frame: frame)
matchPullView = FNMatchPullView.init(frame:CGRect(x: 0, y: 0, width: frame.size.width, height: frame.size.height))
matchPullView.initMatch()
addSubview(matchPullView);
let line = UIView.init(frame: CGRect(x: 0, y: frame.size.height - 1, width: frame.size.width, height: 1))
line.backgroundColor = UIColor(red: 0.7, green: 0.7, blue: 0.7, alpha: 1)
addSubview(line)
}
required public init(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
public func pullToRefresh(_ view: FNPullToRefreshView, progressDidChange progress: CGFloat) {
let validProgress = CGFloat(min(progress, 1.0))
matchPullView.progress = validProgress
matchPullView.center = CGPoint(x: matchPullView.center.x, y: frame.size.height/2 + frame.size.height/2 * (1 - validProgress))
}
public func pullToRefresh(_ view: FNPullToRefreshView, stateDidChange state: FNPullToRefreshViewState) {
}
public func pullToRefreshAnimationDidEnd(_ view: FNPullToRefreshView) {
matchPullView.endBling()
}
public func pullToRefreshAnimationDidStart(_ view: FNPullToRefreshView) {
matchPullView.startBling()
}
}
================================================
FILE: FNMatchPull/FNMatchPull/FNMatchPullMatch.swift
================================================
//
// FNMatchPullMatch.swift
// FNMatchPull
//
// Created by Fnoz on 16/6/25.
// Copyright © 2016年 Fnoz. All rights reserved.
//
import UIKit
class FNMatchPullMatch: UIView {
var angle:CGFloat = 0
var oriCenter:CGPoint = CGPoint(x: 0, y: 0)
}
================================================
FILE: FNMatchPull/FNMatchPull/FNMatchPullView.swift
================================================
//
// FNMatchPullView.swift
// FNMatchPull
//
// Created by Fnoz on 16/6/25.
// Copyright © 2016年 Fnoz. All rights reserved.
//
import UIKit
let horizontalMove = CGFloat(150.0)
let verticalMove = CGFloat(100.0)
let pullViewHeight = CGFloat(80.0)
class FNMatchPullView: UIView {
var lineWidth:CGFloat! = CGFloat(2)
var style:FNMatchPullStyle?
var text:NSString?
var startPoints:NSArray?
var endPoints:NSArray?
var matchViews:NSMutableArray = []
var timer:Timer!
var progress:CGFloat = 0.0 {
didSet {
refreshView(progress)
}
}
override init(frame: CGRect) {
super.init(frame: frame)
startPoints = []
endPoints = []
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func initMatch() {
//remove old matchs
if matchViews.count > 0 {
for i in 0 ... matchViews.count - 1 {
let match = matchViews[i] as! FNMatchPullMatch
match.removeFromSuperview()
}
}
if style == .text {
updateTextToPoints()
}
if startPoints?.count != endPoints?.count || startPoints?.count == 0{
return
}
matchViews.removeAllObjects()
matchViews = NSMutableArray.init(array: [])
//build new matchs
for i in 0 ... (startPoints?.count)! - 1 {
let match = FNMatchPullMatch.init()
match.backgroundColor = UIColor.white
match.alpha = 0.3
let startPoint = (startPoints?[i] as! NSValue).cgPointValue
let endPoint = (endPoints?[i] as! NSValue).cgPointValue
let aaa = (endPoint.x - startPoint.x)*(endPoint.x - startPoint.x)+(endPoint.y - startPoint.y)*(endPoint.y - startPoint.y)
match.frame = CGRect(x: 0, y: 0, width: sqrt(aaa), height: lineWidth)
if i%2 == 0 {
match.center = CGPoint(x: (startPoint.x + endPoint.x)/2 - horizontalMove, y: (startPoint.y + endPoint.y)/2 - verticalMove)
}
else {
match.center = CGPoint(x: (startPoint.x + endPoint.x)/2 + horizontalMove, y: (startPoint.y + endPoint.y)/2 - verticalMove)
}
match.oriCenter = match.center
match.angle = atan((endPoint.y - startPoint.y)/(endPoint.x - startPoint.x)) + CGFloat(M_PI)
let rotate = CGAffineTransform(rotationAngle: CGFloat(-M_PI) + match.angle)
match.transform = rotate.scaledBy(x: 0, y: 0)
addSubview(match)
matchViews.add(match)
}
}
func updateTextToPoints() {
// Fix the issue that app will crash if text is nil
if text == nil {
return
}
let (startPointsNew, endPointsNew) = FNMatchFontParser.parserText(text!, width: self.frame.size.width)
startPoints = startPointsNew
endPoints = endPointsNew
}
func refreshView(_ progress:CGFloat) {
let validProgress = min(progress, 1.0) //限制到1以下
if matchViews.count == 0 {
return
}
for i in 0 ... matchViews.count - 1 {
let duration = 0.6
let interval = CGFloat((1-duration)/Double(matchViews.count - 1))
var progressHandled = (validProgress - CGFloat(i) * interval) / 0.6
if progressHandled<0 {
progressHandled = 0
}
else if progressHandled>1 {
progressHandled = 1
}
let startPoint = (startPoints![i] as! NSValue).cgPointValue
let endPoint = (endPoints![i] as! NSValue).cgPointValue
let centerPoint = CGPoint(x: (startPoint.x + endPoint.x)/2, y: (startPoint.y + endPoint.y)/2)
let newCenterPoint:CGPoint
let match = matchViews[i] as! FNMatchPullMatch
if i%2 == 0 {
newCenterPoint = CGPoint(x: centerPoint.x - horizontalMove * (1 - progressHandled), y: centerPoint.y - verticalMove * (1 - progressHandled))
let rotate = CGAffineTransform(rotationAngle: match.angle + CGFloat(M_PI) * progressHandled)
match.transform = rotate.scaledBy(x: progressHandled, y: progressHandled)
}
else {
newCenterPoint = CGPoint(x: centerPoint.x + horizontalMove * (1 - progressHandled), y: centerPoint.y - verticalMove * (1 - progressHandled))
let rotate = CGAffineTransform(rotationAngle: match.angle + CGFloat(M_PI) * progressHandled)
match.transform = rotate.scaledBy(x: progressHandled, y: progressHandled)
}
match.center = newCenterPoint
}
}
func startBling() {
timer?.invalidate()
timer = nil
timer = Timer.scheduledTimer(timeInterval: 2.1,
target:self,selector:#selector(addAnimation),
userInfo:nil,repeats:true)
timer.fire()
}
@objc func addAnimation() {
if matchViews.count == 0 {
return
}
let interval = 1.3/Double(matchViews.count)
for i in 0 ... matchViews.count - 1 {
let match = matchViews[i] as! FNMatchPullMatch
UIView.animate(withDuration: 0.4, delay: interval * Double(i), options: .curveLinear, animations: {
match.alpha = 1;
}, completion: { (fff) in
UIView.animate(withDuration: 0.3, delay: 0, options: .curveLinear, animations: {
match.alpha = 0.4
}, completion: nil)
})
}
}
func endBling() {
timer?.invalidate()
timer = nil
if matchViews.count == 0 {
return
}
for i in 0 ... matchViews.count - 1 {
let match = matchViews[i] as! FNMatchPullMatch
match.layer.removeAllAnimations()
}
UIView.animate(withDuration: 1, animations: {
self.frame = CGRect(x: self.frame.origin.x, y: pullViewHeight/2, width: self.frame.size.width, height: self.frame.size.height)
})
//delay a bit of time as progress = 0 will perform later
let delayTime = DispatchTime.now() + Double(Int64(0.01 * Double(NSEC_PER_SEC))) / Double(NSEC_PER_SEC)
DispatchQueue.main.asyncAfter(deadline: delayTime) {
for i in 0 ... self.matchViews.count - 1 {
let match = self.matchViews[i] as! FNMatchPullMatch
UIView.animate(withDuration: 0.5, delay: 0.6/Double(self.matchViews.count) * Double(self.matchViews.count - i), options: .curveLinear, animations: {
let rotate = CGAffineTransform(rotationAngle: match.angle)
match.transform = rotate.scaledBy(x: 0.1, y: 0.1)
match.center = match.oriCenter
}, completion: nil)
}
}
}
}
================================================
FILE: FNMatchPull/FNMatchPull/FNPullToRefreshExtension.swift
================================================
//
// PullToRefresh.swift
//
// Copyright (c) 2014 Josip Cavar
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
import Foundation
import UIKit
private let pullToRefreshTag = 324
private let pullToRefreshDefaultHeight: CGFloat = 50
extension UIScrollView {
public var pullToRefreshView: FNPullToRefreshView? {
get {
let pullToRefreshView = viewWithTag(pullToRefreshTag)
return pullToRefreshView as? FNPullToRefreshView
}
}
public func addPullToRefreshWithAction(_ action:@escaping (() -> ())) {
let pullToRefreshView = FNPullToRefreshView(action: action, frame: CGRect(x: 0, y: -pullToRefreshDefaultHeight, width: self.frame.size.width, height: pullToRefreshDefaultHeight))
pullToRefreshView.tag = pullToRefreshTag
addSubview(pullToRefreshView)
}
public func addPullToRefreshWithAction(_ action:@escaping (() -> ()), withAnimator animator: FNPullToRefreshViewDelegate, withSubview subview: UIView) {
let height = subview.frame.height
let pullToRefreshView = FNPullToRefreshView(action: action, frame: CGRect(x: 0, y: -height, width: self.frame.size.width, height: height), animator: animator, subview: subview)
pullToRefreshView.tag = pullToRefreshTag
addSubview(pullToRefreshView)
}
//
public func addPullToRefreshWithAction(_ action:@escaping (() -> ()), withAnimator animator: T) where T: FNPullToRefreshViewDelegate {
let height = animator.frame.height
let pullToRefreshView = FNPullToRefreshView(action: action, frame: CGRect(x: 0, y: -height, width: self.frame.size.width, height: height), animator: animator, subview: animator)
pullToRefreshView.tag = pullToRefreshTag
addSubview(pullToRefreshView)
}
// Manually start pull to refresh
public func startPullToRefresh() {
pullToRefreshView?.loading = true
}
// Manually stop pull to refresh
public func stopPullToRefresh() {
pullToRefreshView?.loading = false
}
}
================================================
FILE: FNMatchPull/FNMatchPull/FNPullToRefreshView.swift
================================================
//
// FNPullToRefreshView.swift
//
// Copyright (c) 2014 Josip Cavar
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
import UIKit
import QuartzCore
private var KVOContext = "RefresherKVOContext"
private let ContentOffsetKeyPath = "contentOffset"
public enum FNPullToRefreshViewState {
case loading
case pullToRefresh
case releaseToRefresh
}
public protocol FNPullToRefreshViewDelegate {
func pullToRefreshAnimationDidStart(_ view: FNPullToRefreshView)
func pullToRefreshAnimationDidEnd(_ view: FNPullToRefreshView)
func pullToRefresh(_ view: FNPullToRefreshView, progressDidChange progress: CGFloat)
func pullToRefresh(_ view: FNPullToRefreshView, stateDidChange state: FNPullToRefreshViewState)
}
open class FNPullToRefreshView: UIView {
fileprivate var scrollViewBouncesDefaultValue: Bool = false
fileprivate var scrollViewInsetsDefaultValue: UIEdgeInsets = UIEdgeInsets.zero
fileprivate var animator: FNPullToRefreshViewDelegate
fileprivate var action: (() -> ()) = {}
fileprivate var previousOffset: CGFloat = 0
internal var loading: Bool = false {
didSet {
if loading != oldValue {
if loading {
startAnimating()
} else {
stopAnimating()
}
}
}
}
//MARK: Object lifecycle methods
convenience init(action :@escaping (() -> ()), frame: CGRect) {
var bounds = frame
bounds.origin.y = 0
let animator = FNAnimator(frame: bounds)
self.init(frame: frame, animator: animator)
self.action = action;
addSubview(animator.animatorView)
}
convenience init(action :@escaping (() -> ()), frame: CGRect, animator: FNPullToRefreshViewDelegate, subview: UIView) {
self.init(frame: frame, animator: animator)
self.action = action;
subview.frame = self.bounds
addSubview(subview)
}
convenience init(action :@escaping (() -> ()), frame: CGRect, animator: FNPullToRefreshViewDelegate) {
self.init(frame: frame, animator: animator)
self.action = action;
}
init(frame: CGRect, animator: FNPullToRefreshViewDelegate) {
self.animator = animator
super.init(frame: frame)
self.autoresizingMask = .flexibleWidth
}
public required init?(coder aDecoder: NSCoder) {
self.animator = FNAnimator(frame: CGRect.zero)
super.init(coder: aDecoder)
// Currently it is not supported to load view from nib
}
deinit {
let scrollView = superview as? UIScrollView
scrollView?.removeObserver(self, forKeyPath: ContentOffsetKeyPath, context: &KVOContext)
}
//MARK: UIView methods
open override func willMove(toSuperview newSuperview: UIView!) {
superview?.removeObserver(self, forKeyPath: ContentOffsetKeyPath, context: &KVOContext)
if let scrollView = newSuperview as? UIScrollView {
scrollView.addObserver(self, forKeyPath: ContentOffsetKeyPath, options: .initial, context: &KVOContext)
scrollViewBouncesDefaultValue = scrollView.bounces
scrollViewInsetsDefaultValue = scrollView.contentInset
}
}
//MARK: KVO methods
open override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
if (context == &KVOContext) {
if let scrollView = superview as? UIScrollView, object as? NSObject == scrollView {
if keyPath == ContentOffsetKeyPath {
let offsetWithoutInsets = previousOffset + scrollViewInsetsDefaultValue.top
if (offsetWithoutInsets < -self.frame.size.height) {
if (scrollView.isDragging == false && loading == false) {
loading = true
} else if (loading) {
self.animator.pullToRefresh(self, stateDidChange: .loading)
} else {
self.animator.pullToRefresh(self, stateDidChange: .releaseToRefresh)
animator.pullToRefresh(self, progressDidChange: -offsetWithoutInsets / self.frame.size.height)
}
} else if (loading) {
self.animator.pullToRefresh(self, stateDidChange: .loading)
} else if (offsetWithoutInsets < 0) {
self.animator.pullToRefresh(self, stateDidChange: .pullToRefresh)
animator.pullToRefresh(self, progressDidChange: -offsetWithoutInsets / self.frame.size.height)
}
previousOffset = scrollView.contentOffset.y
}
}
} else {
super.observeValue(forKeyPath: keyPath, of: object, change: change, context: context)
}
}
//MARK: PullToRefreshView methods
fileprivate func startAnimating() {
let scrollView = superview as! UIScrollView
var insets = scrollView.contentInset
insets.top += self.frame.size.height
// we need to restore previous offset because we will animate scroll view insets and regular scroll view animating is not applied then
scrollView.contentOffset.y = previousOffset
scrollView.bounces = false
UIView.animate(withDuration: 0.3, delay: 0, options: UIViewAnimationOptions(), animations: {
scrollView.contentInset = insets
scrollView.contentOffset = CGPoint(x: scrollView.contentOffset.x, y: -insets.top)
}, completion: {finished in
self.animator.pullToRefreshAnimationDidStart(self)
self.action()
})
}
fileprivate func stopAnimating() {
self.animator.pullToRefreshAnimationDidEnd(self)
let scrollView = superview as! UIScrollView
scrollView.bounces = self.scrollViewBouncesDefaultValue
UIView.animate(withDuration: 1.3, animations: {
scrollView.contentInset = self.scrollViewInsetsDefaultValue
}, completion: { finished in
self.animator.pullToRefresh(self, progressDidChange: 0)
})
}
}
================================================
FILE: FNMatchPull/FNMatchPullTableViewCell.swift
================================================
//
// FNMatchPullTableViewCell.swift
// FNMatchPull
//
// Created by Fnoz on 16/6/24.
// Copyright © 2016年 Fnoz. All rights reserved.
//
import UIKit
class FNMatchPullTableViewCell: UITableViewCell {
var centerImageView: UIImageView = UIImageView.init(frame: CGRect(x: 0, y: 0, width: 80, height: 76))
override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
centerImageView.alpha = 0.5
contentView.addSubview(centerImageView)
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
================================================
FILE: FNMatchPull/Info.plist
================================================
CFBundleDevelopmentRegion
en
CFBundleExecutable
$(EXECUTABLE_NAME)
CFBundleIdentifier
$(PRODUCT_BUNDLE_IDENTIFIER)
CFBundleInfoDictionaryVersion
6.0
CFBundleName
$(PRODUCT_NAME)
CFBundlePackageType
APPL
CFBundleShortVersionString
1.0
CFBundleSignature
????
CFBundleVersion
1
LSRequiresIPhoneOS
UILaunchStoryboardName
LaunchScreen
UIMainStoryboardFile
Main
UIRequiredDeviceCapabilities
armv7
UISupportedInterfaceOrientations
UIInterfaceOrientationPortrait
UIInterfaceOrientationLandscapeLeft
UIInterfaceOrientationLandscapeRight
================================================
FILE: FNMatchPull/ViewController.swift
================================================
//
// ViewController.swift
// FNMatchPull
//
// Created by Fnoz on 16/6/24.
// Copyright © 2016年 Fnoz. All rights reserved.
//
import UIKit
let kScreenWidth = Double(UIScreen.main.bounds.size.width)
let kScreenHeight = Double(UIScreen.main.bounds.size.height)
let kIsXMoreScreen = (kScreenHeight >= 812.0)
let kAdjustedTop = kIsXMoreScreen ? 24.0 : 0.0
class ViewController: UINavigationController, UITableViewDelegate, UITableViewDataSource {
var tableView:UITableView!
override func viewDidLoad() {
super.viewDidLoad()
let titleLabel = UILabel.init(frame: CGRect(x: 10, y: kAdjustedTop + 25, width: 150, height: 44))
titleLabel.text = "FNMatchPullDemo"
titleLabel.textColor = UIColor.init(red: 94/255.0, green: 89/255.0, blue: 151/255.0, alpha: 1)
view.addSubview(titleLabel)
for i in 0 ... 2 {
let btn = UIButton.init(frame: CGRect(x: kScreenWidth - 60 * Double(i + 1), y: kAdjustedTop + 35, width: 45, height: 24))
btn.setTitle(NSString.init(format: "Mode%d", 2 - i) as String, for: UIControlState())
btn.titleLabel?.font = UIFont.systemFont(ofSize: 12)
btn.backgroundColor = UIColor.init(red: 94/255.0, green: 89/255.0, blue: 151/255.0, alpha: 1)
btn.tag = 100 + 2 - i
btn.layer.cornerRadius = 5
view.addSubview(btn)
btn.addTarget(self, action: #selector(modeChange(_:)), for: .touchUpInside)
}
tableView = newTableView()
view.addSubview(tableView)
mode0()
}
@objc func modeChange(_ btn:UIButton) {
tableView?.removeFromSuperview()
tableView = newTableView()
view.addSubview(tableView)
switch btn.tag - 100 {
case 0:
mode0()
break
case 1:
mode1()
break
case 2:
mode2()
break
default:
break
}
}
func mode0() {
let matchAnimator = FNMatchPullAnimator(frame: CGRect(x: 0, y: 0, width: kScreenWidth, height: 80))
matchAnimator.startPoints = [NSValue.init(cgPoint: CGPoint(x: kScreenWidth/2 - 30, y: 25)),
NSValue.init(cgPoint: CGPoint(x: kScreenWidth/2 - 30, y: 55)),
NSValue.init(cgPoint: CGPoint(x: kScreenWidth/2 - 30, y: 55)),
NSValue.init(cgPoint: CGPoint(x: kScreenWidth/2 - 30, y: 25)),
NSValue.init(cgPoint: CGPoint(x: kScreenWidth/2, y: 25)),
NSValue.init(cgPoint: CGPoint(x: kScreenWidth/2, y: 55)),
NSValue.init(cgPoint: CGPoint(x: kScreenWidth/2, y: 55)),
NSValue.init(cgPoint: CGPoint(x: kScreenWidth/2, y: 25)),
NSValue.init(cgPoint: CGPoint(x: kScreenWidth/2 + 30, y: 25)),
NSValue.init(cgPoint: CGPoint(x: kScreenWidth/2 + 30, y: 55)),
NSValue.init(cgPoint: CGPoint(x: kScreenWidth/2 + 30, y: 55)),
NSValue.init(cgPoint: CGPoint(x: kScreenWidth/2 + 30, y: 25))]
matchAnimator.endPoints = [NSValue.init(cgPoint: CGPoint(x: kScreenWidth/2 - 15 - 30, y: 40)),
NSValue.init(cgPoint: CGPoint(x: kScreenWidth/2 - 15 - 30, y: 40)),
NSValue.init(cgPoint: CGPoint(x: kScreenWidth/2 + 15 - 30, y: 40)),
NSValue.init(cgPoint: CGPoint(x: kScreenWidth/2 + 15 - 30, y: 40)),
NSValue.init(cgPoint: CGPoint(x: kScreenWidth/2 - 15, y: 40)),
NSValue.init(cgPoint: CGPoint(x: kScreenWidth/2 - 15, y: 40)),
NSValue.init(cgPoint: CGPoint(x: kScreenWidth/2 + 15, y: 40)),
NSValue.init(cgPoint: CGPoint(x: kScreenWidth/2 + 15, y: 40)),
NSValue.init(cgPoint: CGPoint(x: kScreenWidth/2 - 15 + 30, y: 40)),
NSValue.init(cgPoint: CGPoint(x: kScreenWidth/2 - 15 + 30, y: 40)),
NSValue.init(cgPoint: CGPoint(x: kScreenWidth/2 + 15 + 30, y: 40)),
NSValue.init(cgPoint: CGPoint(x: kScreenWidth/2 + 15 + 30, y: 40))]
tableView.addPullToRefreshWithAction({
OperationQueue().addOperation {
sleep(4)
OperationQueue.main.addOperation {
self.tableView.stopPullToRefresh()
}
}
}, withAnimator: matchAnimator)
}
func mode1() {
let matchAnimator = FNMatchPullAnimator(frame: CGRect(x: 0, y: 0, width: kScreenWidth, height: 80))
matchAnimator.text = "HELLO,FNOZ"
matchAnimator.style = .text
tableView.addPullToRefreshWithAction({
OperationQueue().addOperation {
sleep(4)
OperationQueue.main.addOperation {
self.tableView.stopPullToRefresh()
}
}
}, withAnimator: matchAnimator)
}
func mode2() {
let matchAnimator = FNMatchPullAnimator(frame: CGRect(x: 0, y: 0, width: kScreenWidth, height: 80))
matchAnimator.text = "HELLO,FNOZ"
matchAnimator.style = .text
matchAnimator.lineWidth = 4.0
tableView.addPullToRefreshWithAction({
OperationQueue().addOperation {
sleep(4)
OperationQueue.main.addOperation {
self.tableView.stopPullToRefresh()
}
}
}, withAnimator: matchAnimator)
}
func newTableView() -> UITableView {
let newTableView = UITableView.init(frame: CGRect(x: 0, y: kAdjustedTop + 64, width: kScreenWidth, height: kScreenHeight - 64), style: UITableViewStyle.plain)
newTableView.delegate = self
newTableView.backgroundColor = UIColor.init(red: 45/255.0, green: 45/255.0, blue: 45/255.0, alpha: 1)
newTableView.dataSource = self
newTableView.separatorStyle = .singleLineEtched
newTableView.showsVerticalScrollIndicator = false
return newTableView
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 170
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 4
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
var cell: FNMatchPullTableViewCell? = tableView.dequeueReusableCell(withIdentifier: "FNMatchPullTableViewCell") as? FNMatchPullTableViewCell
if (cell == nil) {
cell = FNMatchPullTableViewCell(style: .default, reuseIdentifier: "FNMatchPullTableViewCell")
}
cell?.contentView.backgroundColor = UIColor.init(red: 45/255.0, green: 45/255.0, blue: 45/255.0, alpha: 1)
cell?.centerImageView.image = UIImage.init(named: NSString.init(format: "icn_%d", (indexPath.row+1)%3) as String)
cell?.centerImageView.center = CGPoint(x: view.bounds.size.width/2, y: 85)
cell?.selectionStyle = UITableViewCellSelectionStyle.none
return cell!
}
}
================================================
FILE: FNMatchPull.podspec
================================================
Pod::Spec.new do |s|
s.name = "FNMatchPull"
s.version = "0.2.1"
s.summary = "A match character and pattern refresh control by Swift."
s.description = <<-DESC
# Features
- Animation can be created by points.
- Animation can be created by English letters.
DESC
s.homepage = "https://github.com/Fnoz/FNMatchPull"
s.license = { :type => "MIT", :file => "LICENSE" }
s.author = { "Lu WJ and Meng Li" => "lm2343635@126.com" }
s.social_media_url = "https://github.com/Fnoz"
s.platform = :ios
s.ios.deployment_target = "8.0"
s.source = { :git => "https://github.com/Fnoz/FNMatchPull.git", :tag => "0.2.1" }
s.source_files = "FNMatchPull/FNMatchPull/*.{swift}"
s.requires_arc = true
end
================================================
FILE: FNMatchPull.xcodeproj/project.pbxproj
================================================
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
10C136B31D1EEF0000D63AAF /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 10C136B21D1EEF0000D63AAF /* AppDelegate.swift */; };
10C136B51D1EEF0000D63AAF /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 10C136B41D1EEF0000D63AAF /* ViewController.swift */; };
10C136B81D1EEF0000D63AAF /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 10C136B61D1EEF0000D63AAF /* Main.storyboard */; };
10C136BA1D1EEF0000D63AAF /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 10C136B91D1EEF0000D63AAF /* Assets.xcassets */; };
10C136BD1D1EEF0000D63AAF /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 10C136BB1D1EEF0000D63AAF /* LaunchScreen.storyboard */; };
10C136CB1D1EEF5D00D63AAF /* FNAnimator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 10C136C51D1EEF5D00D63AAF /* FNAnimator.swift */; };
10C136CC1D1EEF5D00D63AAF /* FNMatchPullAnimator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 10C136C61D1EEF5D00D63AAF /* FNMatchPullAnimator.swift */; };
10C136CD1D1EEF5D00D63AAF /* FNMatchPullMatch.swift in Sources */ = {isa = PBXBuildFile; fileRef = 10C136C71D1EEF5D00D63AAF /* FNMatchPullMatch.swift */; };
10C136CE1D1EEF5D00D63AAF /* FNMatchPullView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 10C136C81D1EEF5D00D63AAF /* FNMatchPullView.swift */; };
10C136CF1D1EEF5D00D63AAF /* FNPullToRefreshExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 10C136C91D1EEF5D00D63AAF /* FNPullToRefreshExtension.swift */; };
10C136D01D1EEF5D00D63AAF /* FNPullToRefreshView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 10C136CA1D1EEF5D00D63AAF /* FNPullToRefreshView.swift */; };
10C136D21D1EEF8A00D63AAF /* FNMatchPullTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 10C136D11D1EEF8A00D63AAF /* FNMatchPullTableViewCell.swift */; };
10C136D41D1F7AA700D63AAF /* FNMatchFontParser.swift in Sources */ = {isa = PBXBuildFile; fileRef = 10C136D31D1F7AA700D63AAF /* FNMatchFontParser.swift */; };
E4A97BEE1E4588DA002D62A4 /* FNMatchPull.podspec in Resources */ = {isa = PBXBuildFile; fileRef = E4A97BEA1E4588DA002D62A4 /* FNMatchPull.podspec */; };
E4A97BEF1E4588DA002D62A4 /* LICENSE in Resources */ = {isa = PBXBuildFile; fileRef = E4A97BEB1E4588DA002D62A4 /* LICENSE */; };
E4A97BF01E4588DA002D62A4 /* README.md in Sources */ = {isa = PBXBuildFile; fileRef = E4A97BEC1E4588DA002D62A4 /* README.md */; };
E4A97BF11E4588DA002D62A4 /* README.zh-CN.md in Sources */ = {isa = PBXBuildFile; fileRef = E4A97BED1E4588DA002D62A4 /* README.zh-CN.md */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
10C136AF1D1EEF0000D63AAF /* FNMatchPull.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = FNMatchPull.app; sourceTree = BUILT_PRODUCTS_DIR; };
10C136B21D1EEF0000D63AAF /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; };
10C136B41D1EEF0000D63AAF /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; };
10C136B71D1EEF0000D63AAF /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; };
10C136B91D1EEF0000D63AAF /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; };
10C136BC1D1EEF0000D63AAF /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; };
10C136BE1D1EEF0000D63AAF /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
10C136C51D1EEF5D00D63AAF /* FNAnimator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FNAnimator.swift; sourceTree = ""; };
10C136C61D1EEF5D00D63AAF /* FNMatchPullAnimator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FNMatchPullAnimator.swift; sourceTree = ""; };
10C136C71D1EEF5D00D63AAF /* FNMatchPullMatch.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FNMatchPullMatch.swift; sourceTree = ""; };
10C136C81D1EEF5D00D63AAF /* FNMatchPullView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FNMatchPullView.swift; sourceTree = ""; };
10C136C91D1EEF5D00D63AAF /* FNPullToRefreshExtension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FNPullToRefreshExtension.swift; sourceTree = ""; };
10C136CA1D1EEF5D00D63AAF /* FNPullToRefreshView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FNPullToRefreshView.swift; sourceTree = ""; };
10C136D11D1EEF8A00D63AAF /* FNMatchPullTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FNMatchPullTableViewCell.swift; sourceTree = ""; };
10C136D31D1F7AA700D63AAF /* FNMatchFontParser.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FNMatchFontParser.swift; sourceTree = ""; };
E4A97BEA1E4588DA002D62A4 /* FNMatchPull.podspec */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = FNMatchPull.podspec; sourceTree = ""; };
E4A97BEB1E4588DA002D62A4 /* LICENSE */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = LICENSE; sourceTree = ""; };
E4A97BEC1E4588DA002D62A4 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = ""; };
E4A97BED1E4588DA002D62A4 /* README.zh-CN.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = "README.zh-CN.md"; sourceTree = ""; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
10C136AC1D1EEF0000D63AAF /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
10C136A61D1EEF0000D63AAF = {
isa = PBXGroup;
children = (
E4A97BE91E4588CE002D62A4 /* Podspec */,
10C136B11D1EEF0000D63AAF /* FNMatchPull */,
10C136B01D1EEF0000D63AAF /* Products */,
);
sourceTree = "";
};
10C136B01D1EEF0000D63AAF /* Products */ = {
isa = PBXGroup;
children = (
10C136AF1D1EEF0000D63AAF /* FNMatchPull.app */,
);
name = Products;
sourceTree = "";
};
10C136B11D1EEF0000D63AAF /* FNMatchPull */ = {
isa = PBXGroup;
children = (
10C136C41D1EEF5D00D63AAF /* FNMatchPull */,
10C136B21D1EEF0000D63AAF /* AppDelegate.swift */,
10C136B41D1EEF0000D63AAF /* ViewController.swift */,
10C136D11D1EEF8A00D63AAF /* FNMatchPullTableViewCell.swift */,
10C136B61D1EEF0000D63AAF /* Main.storyboard */,
10C136B91D1EEF0000D63AAF /* Assets.xcassets */,
10C136BB1D1EEF0000D63AAF /* LaunchScreen.storyboard */,
10C136BE1D1EEF0000D63AAF /* Info.plist */,
);
path = FNMatchPull;
sourceTree = "";
};
10C136C41D1EEF5D00D63AAF /* FNMatchPull */ = {
isa = PBXGroup;
children = (
10C136D31D1F7AA700D63AAF /* FNMatchFontParser.swift */,
10C136C61D1EEF5D00D63AAF /* FNMatchPullAnimator.swift */,
10C136C81D1EEF5D00D63AAF /* FNMatchPullView.swift */,
10C136C71D1EEF5D00D63AAF /* FNMatchPullMatch.swift */,
10C136C51D1EEF5D00D63AAF /* FNAnimator.swift */,
10C136C91D1EEF5D00D63AAF /* FNPullToRefreshExtension.swift */,
10C136CA1D1EEF5D00D63AAF /* FNPullToRefreshView.swift */,
);
path = FNMatchPull;
sourceTree = "";
};
E4A97BE91E4588CE002D62A4 /* Podspec */ = {
isa = PBXGroup;
children = (
E4A97BEA1E4588DA002D62A4 /* FNMatchPull.podspec */,
E4A97BEB1E4588DA002D62A4 /* LICENSE */,
E4A97BEC1E4588DA002D62A4 /* README.md */,
E4A97BED1E4588DA002D62A4 /* README.zh-CN.md */,
);
name = Podspec;
sourceTree = "";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
10C136AE1D1EEF0000D63AAF /* FNMatchPull */ = {
isa = PBXNativeTarget;
buildConfigurationList = 10C136C11D1EEF0000D63AAF /* Build configuration list for PBXNativeTarget "FNMatchPull" */;
buildPhases = (
10C136AB1D1EEF0000D63AAF /* Sources */,
10C136AC1D1EEF0000D63AAF /* Frameworks */,
10C136AD1D1EEF0000D63AAF /* Resources */,
);
buildRules = (
);
dependencies = (
);
name = FNMatchPull;
productName = FNMatchPull;
productReference = 10C136AF1D1EEF0000D63AAF /* FNMatchPull.app */;
productType = "com.apple.product-type.application";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
10C136A71D1EEF0000D63AAF /* Project object */ = {
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0730;
LastUpgradeCheck = 0730;
ORGANIZATIONNAME = Fnoz;
TargetAttributes = {
10C136AE1D1EEF0000D63AAF = {
CreatedOnToolsVersion = 7.3.1;
LastSwiftMigration = 0820;
};
};
};
buildConfigurationList = 10C136AA1D1EEF0000D63AAF /* Build configuration list for PBXProject "FNMatchPull" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
English,
en,
Base,
);
mainGroup = 10C136A61D1EEF0000D63AAF;
productRefGroup = 10C136B01D1EEF0000D63AAF /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
10C136AE1D1EEF0000D63AAF /* FNMatchPull */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
10C136AD1D1EEF0000D63AAF /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
10C136BD1D1EEF0000D63AAF /* LaunchScreen.storyboard in Resources */,
E4A97BEE1E4588DA002D62A4 /* FNMatchPull.podspec in Resources */,
10C136BA1D1EEF0000D63AAF /* Assets.xcassets in Resources */,
10C136B81D1EEF0000D63AAF /* Main.storyboard in Resources */,
E4A97BEF1E4588DA002D62A4 /* LICENSE in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
10C136AB1D1EEF0000D63AAF /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
10C136CB1D1EEF5D00D63AAF /* FNAnimator.swift in Sources */,
10C136CF1D1EEF5D00D63AAF /* FNPullToRefreshExtension.swift in Sources */,
E4A97BF11E4588DA002D62A4 /* README.zh-CN.md in Sources */,
10C136CC1D1EEF5D00D63AAF /* FNMatchPullAnimator.swift in Sources */,
10C136CD1D1EEF5D00D63AAF /* FNMatchPullMatch.swift in Sources */,
10C136D01D1EEF5D00D63AAF /* FNPullToRefreshView.swift in Sources */,
10C136D21D1EEF8A00D63AAF /* FNMatchPullTableViewCell.swift in Sources */,
10C136CE1D1EEF5D00D63AAF /* FNMatchPullView.swift in Sources */,
10C136D41D1F7AA700D63AAF /* FNMatchFontParser.swift in Sources */,
10C136B51D1EEF0000D63AAF /* ViewController.swift in Sources */,
E4A97BF01E4588DA002D62A4 /* README.md in Sources */,
10C136B31D1EEF0000D63AAF /* AppDelegate.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXVariantGroup section */
10C136B61D1EEF0000D63AAF /* Main.storyboard */ = {
isa = PBXVariantGroup;
children = (
10C136B71D1EEF0000D63AAF /* Base */,
);
name = Main.storyboard;
sourceTree = "";
};
10C136BB1D1EEF0000D63AAF /* LaunchScreen.storyboard */ = {
isa = PBXVariantGroup;
children = (
10C136BC1D1EEF0000D63AAF /* Base */,
);
name = LaunchScreen.storyboard;
sourceTree = "";
};
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
10C136BF1D1EEF0000D63AAF /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.3;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
};
name = Debug;
};
10C136C01D1EEF0000D63AAF /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.3;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
VALIDATE_PRODUCT = YES;
};
name = Release;
};
10C136C21D1EEF0000D63AAF /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = FNMatchPull/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = Fnoz.FNMatchPull;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
};
name = Debug;
};
10C136C31D1EEF0000D63AAF /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = FNMatchPull/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = Fnoz.FNMatchPull;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
10C136AA1D1EEF0000D63AAF /* Build configuration list for PBXProject "FNMatchPull" */ = {
isa = XCConfigurationList;
buildConfigurations = (
10C136BF1D1EEF0000D63AAF /* Debug */,
10C136C01D1EEF0000D63AAF /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
10C136C11D1EEF0000D63AAF /* Build configuration list for PBXNativeTarget "FNMatchPull" */ = {
isa = XCConfigurationList;
buildConfigurations = (
10C136C21D1EEF0000D63AAF /* Debug */,
10C136C31D1EEF0000D63AAF /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 10C136A71D1EEF0000D63AAF /* Project object */;
}
================================================
FILE: FNMatchPull.xcodeproj/project.xcworkspace/contents.xcworkspacedata
================================================
================================================
FILE: FNMatchPull.xcodeproj/xcuserdata/Fnoz.xcuserdatad/xcschemes/FNMatchPull.xcscheme
================================================
================================================
FILE: LICENSE
================================================
Copyright (c) 2017 FNMatchPull
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
================================================
FILE: README.md
================================================
# FNMatchPull  [](https://cocoapods.org/pods/UIImageView+Extension) []() [](https://github.com/lm2343635/UIImageView-Extension/LICENSE)
A match character and pattern refresh control by Swift based in [CBStoreHouseRefreshControl](https://github.com/coolbeet/CBStoreHouseRefreshControl).
Simplified Chinese is here [简体中文](https://github.com/Fnoz/FNMatchPull/blob/master/README.zh-CN.md).
### Installation
Installing FNMatchPull by [CocoaPods](http://cocoapods.org/).
```ruby
pod 'FNMatchPull', '~> 0.2'
```
### Demo:
#### Style = .Pattern
Animation can be created by points.
```
let matchAnimator = FNMatchPullAnimator(frame: CGRectMake(0, 0, 320, 80))
matchAnimator.startPoints = [NSValue.init(CGPoint: CGPointMake(SCREENWIDTH/2 - 30, 25)),
NSValue.init(CGPoint: CGPointMake(SCREENWIDTH/2 - 30, 55))]
matchAnimator.endPoints = [NSValue.init(CGPoint: CGPointMake(SCREENWIDTH/2 - 15 - 30, 40)),
NSValue.init(CGPoint: CGPointMake(SCREENWIDTH/2 - 15 - 30, 40))]
tableView.addPullToRefreshWithAction({
//refresh action
}, withAnimator: matchAnimator)
```
#### Style = .Text
Animation can be created by English letters. Line width can be defined by yourself.
```
let matchAnimator = FNMatchPullAnimator(frame: CGRectMake(0, 0, 320, 80))
matchAnimator.text = "FNOZ"
matchAnimator.lineWidth = 4.0
matchAnimator.style = .Text
tableView.addPullToRefreshWithAction({
//refresh action
}, withAnimator: matchAnimator)
```
### Effect:



### Source:
The Objective-C edition is [CBStoreHouseRefreshControl](https://github.com/coolbeet/CBStoreHouseRefreshControl) by [coolbeet](https://github.com/coolbeet).
Our FNMatchPull can transfer English letters to pattern direclty.
================================================
FILE: README.zh-CN.md
================================================
# FNMatchPull  [](https://cocoapods.org/pods/UIImageView+Extension) []() [](https://github.com/lm2343635/UIImageView-Extension/LICENSE)
Swift实现的火柴图案&火柴文字下拉刷新动效(超炫酷下拉刷新),Swift&加强版本CBStoreHouseRefreshControl.
### 安装
通过[CocoaPods](http://cocoapods.org/)安装,手动安装直接将FNMatchPull/FNMatchPull目录下的文件复制到工程中。
```ruby
pod 'FNMatchPull', '~> 0.2'
```
### 基础使用Demo
#### Style = .Pattern类型
动画内容为火柴棒组成的图案
```
let matchAnimator = FNMatchPullAnimator(frame: CGRectMake(0, 0, 320, 80))
matchAnimator.startPoints = [NSValue.init(CGPoint: CGPointMake(SCREENWIDTH/2 - 30, 25)),
NSValue.init(CGPoint: CGPointMake(SCREENWIDTH/2 - 30, 55))]
matchAnimator.endPoints = [NSValue.init(CGPoint: CGPointMake(SCREENWIDTH/2 - 15 - 30, 40)),
NSValue.init(CGPoint: CGPointMake(SCREENWIDTH/2 - 15 - 30, 40))]
tableView.addPullToRefreshWithAction({
//refresh action
}, withAnimator: matchAnimator)
```
#### Style = .Text类型
传入英文字符串,自动转换为图案动画,可自定义线条宽度
```
let matchAnimator = FNMatchPullAnimator(frame: CGRectMake(0, 0, 320, 80))
matchAnimator.text = "FNOZ"
matchAnimator.lineWidth = 4.0
matchAnimator.style = .Text
tableView.addPullToRefreshWithAction({
//refresh action
}, withAnimator: matchAnimator)
```
### 效果



### 来源
OC原版是 [coolbeet](https://github.com/coolbeet) 的 [CBStoreHouseRefreshControl](https://github.com/coolbeet/CBStoreHouseRefreshControl),另外增加了酷酷的直接把英文字符串变成图片的功能。