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
git config --global http.proxy 'socks5://127.0.0.1:1080' | |
git config --global https.proxy 'socks5://127.0.0.1:1080' |
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 animateWithDuration:.1 delay:0 options:UIViewAnimationOptionRepeat | UIViewAnimationOptionAutoreverse | UIViewAnimationOptionAllowUserInteraction animations:^{ | |
cell.transform = CGAffineTransformMakeRotation(.02); | |
} completion:nil]; |
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
// 去除所有返回按钮文字 | |
UIBarButtonItem.appearance().setBackButtonTitlePositionAdjustment(UIOffsetMake(-100, 0), for:UIBarMetrics.default) |
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
BOOL animating; | |
BOOL animationPending; | |
BOOL animationComplete; | |
- (void)rotateWithOptions:(UIViewAnimationOptions)options { | |
NSTimeInterval fullRotationInterval = 4.0; | |
[UIView animateWithDuration:fullRotationInterval/4.0 delay:0 options:options animations:^{ | |
self.musicIconImageView.transform = CGAffineTransformRotate(self.musicIconImageView.transform, M_PI_2); | |
} completion:^(BOOL finished) { | |
if (animating) { |
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 <openssl/dsa.h> | |
#import <openssl/pem.h> | |
- (NSString *)DASSignatureStringWithPublicKey:(NSString *)publicKey privateKey:(NSString *)privateKey { | |
const char *message = [self UTF8String]; | |
BIO *publicBIO = BIO_new_mem_buf((void *)[publicKey UTF8String], -1); | |
DSA *publicDSA = PEM_read_bio_DSA_PUBKEY(publicBIO, NULL, NULL, NULL); | |
BIO_free_all(publicBIO); | |
BIO *privateBIO = BIO_new_mem_buf((void *)[privateKey UTF8String], -1); |
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增加抖动方法 | |
/// | |
/// - Parameters: | |
/// - direction: 抖动方向(默认是水平方向) | |
/// - times: 抖动次数(默认6次) | |
/// - interval: 每次抖动时间(默认0.2秒) | |
/// - delta: 抖动偏移量(默认4) | |
/// - completion: 抖动动画结束后的回调 | |
public func shake(direction: ShakeDirection = .horizontal, times: Int = 6, interval: TimeInterval = 0.2, delta: CGFloat = 4, completion: (() -> Void)? = nil) { | |
//播放动画 |
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
// 放射渐变 | |
CGContextRef context = UIGraphicsGetCurrentContext(); | |
size_t num_locations = 2; | |
CGColorSpaceRef rgb = CGColorSpaceCreateDeviceRGB(); | |
CGFloat components[8] = {1,1,1,1, // 中心颜色(r, g, b, alpha) | |
.2,.2,.2,1 // 边缘颜色}; | |
CGFloat locations[2] = {0,1}; | |
CGGradientRef gradient = CGGradientCreateWithColorComponents(rgb, components, locations, num_locations); |
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 <sys/sysctl.h> | |
#import <mach/mach.h> | |
+ (double)getAvailableMemory | |
{ | |
vm_statistics_data_t vmStats; | |
mach_msg_type_number_t infoCount = HOST_VM_INFO_COUNT; | |
kern_return_t kernReturn = host_statistics(mach_host_self(), | |
HOST_VM_INFO, | |
(host_info_t)&vmStats, |
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
[[[NSURLSession sharedSession] downloadTaskWithURL:[NSURL URLWithString:@"https://alpha.migufun.com:38081/alpha/manifest.plist"] completionHandler:^(NSURL * _Nullable location, NSURLResponse * _Nullable response, NSError * _Nullable error) { | |
NSDictionary *plist = [[NSDictionary alloc] initWithContentsOfURL:location]; | |
NSString *version = plist[@"items"][0][@"metadata"][@"bundle-version"]; | |
NSString *currentVersion = [NSBundle mainBundle].infoDictionary[@"CFBundleShortVersionString"]; | |
if ([version compare:currentVersion options:NSNumericSearch] == NSOrderedDescending) { | |
// 需要升级 | |
NSURL *url = [NSURL URLWithString:@"itms-services://?action=download-manifest&url=https://alpha.migufun.com:38081/alpha/manifest.plist"]; | |
dispatch_async(dispatch_get_main_queue(), ^{ | |
[[UIApplication sharedApplication] openURL:url]; |
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
NSURL *soundURL = [[NSBundle mainBundle] URLForResource:@"shake" withExtension:@"wav"]; | |
SystemSoundID soundID; | |
AudioServicesCreateSystemSoundID((__bridge CFURLRef _Nonnull)(soundURL), &soundID); | |
AudioServicesPlaySystemSound(soundID); |