This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//https://developer.apple.com/documentation/uikit/uitableviewdelegate/selecting_multiple_items_with_a_two-finger_pan_gesture | |
//CollectionViewCell.swift | |
//===================== | |
/* | |
See LICENSE folder for this sample’s licensing information. | |
Abstract: | |
A custom collection view cell that `CollectionViewController` displays. | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Collection+SF.swift | |
// PanoAI | |
// | |
// Created by Forever Positive on 2021/1/30. | |
// | |
import Foundation | |
extension Array where Element == Optional<Any>{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
extension UIRefreshControl { | |
func beginRefreshingManually(_ tintColor:UIColor) { | |
self.tintColor = tintColor | |
if let scrollView = superview as? UIScrollView { | |
scrollView.setContentOffset(CGPoint(x: 0, y:scrollView.contentOffset.y - frame.height), animated: false) | |
} | |
beginRefreshing() | |
self.sendActions(for: .valueChanged) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let targetWidth = self.view.bounds.size.width; | |
let targetSize = CGSize(width: targetWidth, height: UIView.layoutFittingCompressedSize.height) | |
//如果headView中有通过aspect ratio决定高度的constraint,这将导致systemLayoutSizeFittingSize计算错误,所以在代码中把这种constraint转为固定高度的constraint | |
//see : https://stackoverflow.com/questions/44801492/systemlayoutsizefitting-ignoring-layout-constraints-and-using-image-view-intrins | |
let imageView = self.empyHeadView.subviews.last! | |
imageView.constraintWithIdentifier("heightConstraint")!.constant = (targetWidth - 40) * CGFloat(0.3); | |
//宽度固定,高度可变 | |
let resultSize = self.empyHeadView.systemLayoutSizeFitting(targetSize, withHorizontalFittingPriority: UILayoutPriority.defaultHigh, verticalFittingPriority:UILayoutPriority.fittingSizeLevel ); | |
//set |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension UIView { | |
func findDescendantViewsOfType<T: Any>(_ subViewType:T.Type) -> [T]{ | |
var rs = [T]() | |
if self is T { | |
rs.append(self as! T) | |
} | |
for view in self.subviews { | |
rs.append(contentsOf: view.findDescendantViewsOfType(T.self)) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// UIView+SF.swift | |
// WechatTail | |
// | |
// Created by CHENWANFEI on 2019/9/22. | |
// Copyright © 2019 SwordFish. All rights reserved. | |
// | |
import UIKit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let query = NSMetadataQuery(); | |
query.searchScopes = ["/work/books"] | |
query.predicate = NSPredicate(format: "kMDItemFSName like %@", "NSHipster - Cocoa & Swift.pdf") | |
NotificationCenter.default.addObserver(forName: NSNotification.Name.NSMetadataQueryDidFinishGathering, object: query, queue: nil) { (_) in | |
print("count = \(query.resultCount)") | |
if let items = query.results as? [NSMetadataItem]{ | |
for item in items{ | |
if let path = item.value(forKey: NSMetadataItemPathKey) as? String{ | |
print(path) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// UIViewController+SF.swift | |
// BowenEdu | |
// | |
// Created by CHENWANFEI on 2018/8/21. | |
// Copyright © 2018 swordfish. All rights reserved. | |
// | |
import UIKit | |
extension UIViewController{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.ByteArrayOutputStream; | |
import java.io.File; | |
import java.io.IOException; | |
import java.io.InputStream; | |
import java.nio.charset.Charset; | |
import java.nio.file.Files; | |
import java.nio.file.Paths; |