Skip to content

Instantly share code, notes, and snippets.

View MadeBugs's full-sized avatar

J.M MadeBugs

View GitHub Profile
@MadeBugs
MadeBugs / getSize.m
Created April 22, 2019 03:36
计算文字高度
CGSize size = [info[@"entry"] boundingRectWithSize:CGSizeMake(260, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14]} context:nil].size;
@MadeBugs
MadeBugs / HTMLToPDF.m
Created April 2, 2019 05:55
HTML网页导出PDF文件
- (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;
@MadeBugs
MadeBugs / AirPrint.m
Created March 29, 2019 01:17
Airprint
- (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];
@MadeBugs
MadeBugs / DynamicChangeIcon.m
Created March 23, 2019 08:55
动态更换APP图标
//判断是否支持更换图标
if(![[UIApplication sharedApplication] supportsAlternateIcons]) {
return;
}
//更换icon,传入图标文件名
[[UIApplication sharedApplication] setAlternateIconName:@"shuiguo" completionHandler:^(NSError * _Nullable error) {
}];
@MadeBugs
MadeBugs / StringEncode.m
Last active October 24, 2024 03:32
特殊字符转码
//特殊字符转码
- (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]];
@MadeBugs
MadeBugs / view.css
Last active March 14, 2019 08:53
水平垂直居中
.view {
display: flex;
align-items: center;
justify-content: center;
}