1、可以预热加载控制器,后面进去控制器会快;
2、UICollectionView当前显示最小和最大index:
guard let minIndex = collectionView.indexPathsForVisibleItems.min() else { return }
guard let maxIndex = collectionView.indexPathsForVisibleItems.max() else { return }
3、添加多个视图:
view.addSubviews([bgImageView,bottomView,topBarView,topPotView,topOtherPotView,topMaterialView,bottomPotCountView,bottomHistoryView,personView,personViewTemp,tipsView,sigleView,doubleView,fourView,bottomSureView,sureView,doneView,levelView])
4、extension写法:
@objc private
extension MYViewController {
}
5、iOS多状态多用enum
6、获取gif文件:
extension URL {
static func gif(name: String) -> URL? {
guard let bundleURL = Bundle.main
.url(forResource: name, withExtension: "gif") else {
print("SwiftGif: This image named \"\(name)\" does not exist")
return nil
}
return bundleURL
}
}
7、通知的分类:
extension Notification.Name {
public static let showHistoryPotDetail = Notification.Name("XXX")
}
8、好用的第三方:
pod 'Spring', :git => 'https://github.com/MengTo/Spring.git'
pod 'SwifterSwift'
网友评论