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
| .view { | |
| display: flex; | |
| align-items: center; | |
| justify-content: center; | |
| } |
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
| //特殊字符转码 | |
| - (NSString *)encodeWithString:(NSString *)string { | |
| NSString *charactersToEscape = @"?!@#$^&%*+,:;='\"`<>()[]{}/\\| "; | |
| NSCharacterSet *allowedCharacters = [[NSCharacterSet characterSetWithCharactersInString:charactersToEscape] invertedSet]; | |
| return [string stringByAddingPercentEncodingWithAllowedCharacters:allowedCharacters]; | |
| } | |
| //URL中包含中文的连接转码 | |
| NSString *escapedPath = [@"http://www.baidu.com?中文" stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]]; |
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
| //判断是否支持更换图标 | |
| if(![[UIApplication sharedApplication] supportsAlternateIcons]) { | |
| return; | |
| } | |
| //更换icon,传入图标文件名 | |
| [[UIApplication sharedApplication] setAlternateIconName:@"shuiguo" completionHandler:^(NSError * _Nullable error) { | |
| }]; |
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
| - (void)testAirPrint{ | |
| UIPrintInteractionController *pic = [UIPrintInteractionController sharedPrintController]; | |
| pic.delegate = self; | |
| UIPrintInfo *printInfo = [UIPrintInfo printInfo]; | |
| printInfo.outputType = UIPrintInfoOutputGeneral; | |
| printInfo.jobName = self.webView.URL.scheme; | |
| pic.printInfo = printInfo; | |
| UIViewPrintFormatter *viewFormatter = [self.webView viewPrintFormatter]; |
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
| - (void)htmlExpectToPDF{ | |
| UIViewPrintFormatter *viewPrintFormatter = [self.webView viewPrintFormatter]; | |
| viewPrintFormatter.startPage = 0; | |
| UIPrintPageRenderer *pageRender = [[UIPrintPageRenderer alloc] init]; | |
| [pageRender addPrintFormatter:viewPrintFormatter startingAtPageAtIndex:0]; | |
| CGRect page; | |
| page.origin.x=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
| CGSize size = [info[@"entry"] boundingRectWithSize:CGSizeMake(260, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14]} context:nil].size; |
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
| if [ $CONFIGURATION == Debug ]; then | |
| echo "当前为 Release Configuration,开始自增 Build" | |
| plist=${INFOPLIST_FILE} | |
| buildnum=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "${plist}") | |
| if [[ "${buildnum}" == "" ]]; then | |
| echo "Error:在Plist文件里没有 Build 值" | |
| exit 2 | |
| fi | |
| buildnum=$(expr $buildnum + 1) | |
| /usr/libexec/PlistBuddy -c "Set CFBundleVersion $buildnum" "${plist}" |
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
| // 截取屏幕生成UIImage | |
| func shoutScreen() -> UIImage { | |
| let render = UIGraphicsImageRenderer(size: (window?.bounds.size)!) | |
| let image = render.image { (ctx) in | |
| window?.drawHierarchy(in: window!.bounds, afterScreenUpdates: false) | |
| } | |
| return img | |
| } |
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
| // 如果是系统的弹窗,则无法获取到,比如在用Airprint,这时是无法获取到的,结果为nil | |
| func getPrexxx() -> UIViewController { | |
| var result = UIApplication.shared.keyWindow?.rootViewController | |
| while ((result?.presentedViewController) != nil) { | |
| result = result?.presentedViewController | |
| } | |
| return result | |
| } |
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
| //要先添加到view上,不然不显示, | |
| TextView.addSubview(label) | |
| TextView.setValue(label, forKey: "_placeholderLabel") |
OlderNewer