启动屏中要添加图片经常会出现图片无法展示的问题
查了很多资料,最后得出一个对我来说有用的结论
1、将图片添加到根目录中
2、将图片添加到Assets.xcassets中
3、在LaunchScreen.storyboard中添加一个UIImageView,然后添加Assets.scassets中的图片即可
This file contains hidden or 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 <mach/mach.h> | |
#import <sys/sysctl.h> | |
+ (double)cpuUsage { | |
kern_return_t kr; | |
task_info_data_t tinfo; | |
mach_msg_type_number_t task_info_count; | |
task_info_count = TASK_INFO_MAX; | |
kr = task_info(mach_task_self(), TASK_BASIC_INFO, (task_info_t)tinfo, &task_info_count); |
This file contains hidden or 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
func resolveDictionary(fromTXTRecord data: Data) -> [String: String] { | |
var dict = [String: String]() | |
var offset = 0 | |
let bytes = data.bytes | |
while offset < bytes.count { | |
let recordLength = Int(bytes[offset]) | |
offset += 1 | |
print(recordLength) | |
if recordLength > 0 { | |
let subBytes = bytes[offset..<offset + recordLength] |
This file contains hidden or 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 resources = PHAssetResource.assetResources(for: asset) | |
let videoResource = resources.first(where: { $0.type == .video || $0.type == .pairedVideo })! | |
let url = URL(fileURLWithPath: FileManager.Folder.tmp.append(pathComponent: "test.MOV")) | |
let resourceOptions = PHAssetResourceRequestOptions() | |
resourceOptions.isNetworkAccessAllowed = true | |
PHAssetResourceManager.default().writeData(for: videoResource, toFile: url, options: resourceOptions, completionHandler: { (error) in | |
print(error == nil) | |
}) |
This file contains hidden or 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
expr (Class)NSClassFromString(@"IBARevealLoader") == nil ? (void *)dlopen("/Applications/Reveal.app/Contents/SharedSupport/iOS-Libraries/RevealServer.framework/RevealServer", 0x2) : ((void*)0) |
This file contains hidden or 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
#define clamp(a) (a>255?255:(a<0?0:a)) | |
+ (UIImage *)imageFromSampleBuffer:(CMSampleBufferRef)sampleBuffer { | |
CVImageBufferRef imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer); | |
CVPixelBufferLockBaseAddress(imageBuffer, 0); | |
if (CVPixelBufferGetPlaneCount(imageBuffer) < 2) { | |
CVPixelBufferUnlockBaseAddress(imageBuffer, 0); | |
return nil; | |
} |
This file contains hidden or 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 isBlackColor = { (x: Int, y: Int) -> Bool in | |
let byteIndex = (bytesPerRow * y) + x * bytesPerPixel | |
let r = CGFloat(rawData[byteIndex]) | |
let g = CGFloat(rawData[byteIndex + 1]) | |
let b = CGFloat(rawData[byteIndex + 2]) | |
// https://stackoverflow.com/a/12043228 | |
let luma = 0.2126 * r + 0.7152 * g + 0.0722 * b | |
return luma < 40 | |
} |
在Swift中使用Google Nearby API的时候,遇到了以下错误
Undefined symbols for architecture arm64:
"OBJC_CLASS$_GNSMessageManager", referenced from:
objc-class-ref in TBGNSMessager.o
"OBJC_CLASS$_GNSMessage", referenced from:
objc-class-ref in TBGNSMessager.o
This file contains hidden or 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 Accelerate.vImage | |
func getImageBuffer(from pixelBuffer: CVPixelBuffer) -> vImage_Buffer? { | |
var buffer = vImage_Buffer() | |
let bitmapInfo = CGBitmapInfo(rawValue: CGBitmapInfo.byteOrder32Little.rawValue | CGImageAlphaInfo.first.rawValue) | |
var cgFormat = vImage_CGImageFormat(bitsPerComponent: 8, | |
bitsPerPixel: 32, | |
colorSpace: nil, | |
bitmapInfo: bitmapInfo, | |
version: 0, |
OlderNewer