ForgetSou | Blog

❤ 武统台湾 刻不容缓 ❤

0%

1.删除ToolBar下面的分割线

toolbar.showsBaselineSeparator = NO;

2.修改TextField的蓝色或橙色边框

self.textField.focusRingType = NSFocusRingTypeNone;

3.打开已安装的其他软件

// 1
NSString *appPath = @"/Applications/Foxmail.app";
[[NSWorkspace sharedWorkspace] openFile:appPath];
// 2
[[NSWorkspace sharedWorkspace] launchApplication:@"Foxmail"];

4.打开网页

[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"https://www.baidu.com"]];

5.Color生成纯色图片(iOS)

// 生成纯色图片

+ (UIImage *)pureColorImageWithColor:(UIColor *)color {
CGSize imageSize = CGSizeMake(1.0f, 1.0f);
UIGraphicsBeginImageContextWithOptions(imageSize, NO, 0.0f);

CGContextRef theContext = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(theContext, color.CGColor);
CGContextFillRect(theContext, CGRectMake(0.0f, 0.0f, imageSize.width, imageSize.height));

CGImageRef theCGImage = CGBitmapContextCreateImage(theContext);
UIImage *theImage;
if ([[UIImage class] respondsToSelector:@selector(imageWithCGImage:scale:orientation:)]) {
theImage = [UIImage imageWithCGImage:theCGImage scale:[UIScreen mainScreen].scale orientation:UIImageOrientationUp];
} else {
theImage = [UIImage imageWithCGImage:theCGImage];
}
CGImageRelease(theCGImage);

return theImage;
}
// 生成纯色圆角图片

+ (UIImage *)pureColorImageWithSize:(CGSize)size
color:(UIColor *)color
cornRadius:(CGFloat)radius {
UIGraphicsBeginImageContextWithOptions(size, NO, 0);
CGContextRef cxt = UIGraphicsGetCurrentContext();

CGContextSetFillColorWithColor(cxt, color.CGColor);
CGContextSetStrokeColorWithColor(cxt, color.CGColor);

CGContextMoveToPoint(cxt, size.width, size.height-radius);
CGContextAddArcToPoint(cxt, size.width, size.height, size.width-radius, size.height, radius);//右下角
CGContextAddArcToPoint(cxt, 0, size.height, 0, size.height-radius, radius);//左下角
CGContextAddArcToPoint(cxt, 0, 0, radius, 0, radius);//左上角
CGContextAddArcToPoint(cxt, size.width, 0, size.width, radius, radius);//右上角
CGContextClosePath(cxt);
CGContextDrawPath(cxt, kCGPathFillStroke);
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}
阅读全文 »

1.LGAlertView库viewWillTransitionToSize崩溃

- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator {
[super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];

__weak typeof(self) weakSelf = self;
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[UIView animateWithDuration:coordinator.transitionDuration animations:^{
[self setNeedsStatusBarAppearanceUpdate];
[self.alertView layoutValidateWithSize:size];
}];
});
}

-[_UIViewControllerOneToOneTransitionContext _duration]: message sent to deallocated instance

po coordinator.transitionDuration输出 error: property 'transitionDuration' not found on object of type 'id'

解决方法:

使用硬编码的持续时间,pod 'LGAlertView'更改为vovnit的派生库

pod 'LGAlertView', :git => 'https://github.com/vovnit/LGAlertView.git'

vovnit的派生库的具体解决方案

@vovnit的具体解决方式如下:

- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator {
if (coordinator) {
[super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
}

@try {
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
__weak typeof(self) weakSelf = self;
[UIView animateWithDuration:0.5 animations:^{
if (weakSelf) {
if ([weakSelf respondsToSelector:@selector(setNeedsStatusBarAppearanceUpdate)]) {
[weakSelf setNeedsStatusBarAppearanceUpdate];
}
if (weakSelf.alertView) {
[weakSelf.alertView layoutValidateWithSize:size];
}
}
}];
}];
} @catch (NSException *exception) {
//
} @finally {
//
}
}
阅读全文 »