当我们需要组合多个UIView动画的时候,可以使用UIView.animate嵌套,也可以使用keyframe完成,这个是ios7+支持的。
self.badgeView.transform = CGAffineTransform(scaleX: 0.01, y: 0.01)
self.badgeView.alpha = 0
UIView.animateKeyframes(withDuration: 5, delay: 0.0, option[......]
Author Archives: coder4
H5如何访问ios本地图片
import UIKit
class NSLocalImageURLProtocol: URLProtocol {
static let schemaName = "myapp"
override class func canInit(with request: URLRequest) -> Bool {
if let schema = request.url?.scheme?.lowercased(),
sch[......]
Swift中,如何等到多个回调都完成后再执行
var myGroup = DispatchGroup()
override func viewDidLoad() {
super.viewDidLoad()
for i in 0 ..< 5 {
myGroup.enter()
Alamofire.request("https://httpbin.org/get", parameters: ["foo": "bar"]).responseJSON { response[......]
Swift的Array如何过滤数组中的nil数据 - 用flatMap
As of Swift 2.0, you don't need to write your own extension to filter nil values from an Array, you can use flatMap, which flattens the Array and filters nils:
let optionals : [String?] = ["a", "b", nil, "d"]
let nonOptionals = optionals.flatMap{$0[......]
YYTextView与AutoLayout混用Demo
import UIKit
import YYText
import SnapKit
class YYCell: UITableViewCell {
fileprivate static let fontSize: CGFloat = 24
fileprivate static let font = UIFont.systemFont(ofSize: YYCell.fontSize)
fileprivate lazy var wrapView: UI[......]