日常随笔

1.复制
UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
        [pasteboard setString:self.cutStr];
 
2.状态栏
[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault;
 
3.设置导航栏按钮的位置
UIBarButtonItem *space = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
    space.width = -11;
    [self.navigationItem setRightBarButtonItems:[NSArray arrayWithObjects:space,rightItem, nil]];
 
4.UILabel内容省略部分
_nameLabel.lineBreakMode = NSLineBreakByTruncatingMiddle;//省略号在中间
 
5.NSUserDefaults是定时把缓存中的数据写入磁盘的,而不是即时写入,为了防止在写完NSUserDefaults后程序退出导致的数据丢失,可以在写入数据后使用synchronize强制立即将数据写入磁盘
 
6.视图旋转
self.infoButton.transform=CGAffineTransformRotate(self.infoButton.transform, M_PI);
 
7.关闭侧滑返回
 self.rt_disableInteractivePop = YES;
 
8.显示html标签
NSString * htmlString = @"<html><body> Some html string \n <font size=\"13\" color=\"red\">This is some text!</font> </body></html>";
        NSAttributedString * attrStr = [[NSAttributedString alloc] initWithData:[htmlString dataUsingEncoding:NSUnicodeStringEncoding] options:@{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType } documentAttributes:nil error:nil];
        UILabel * myLabel = [[UILabel alloc] initWithFrame:self.bounds];
        myLabel.attributedText = attrStr;
        [self addSubview:myLabel];
 
9.提取html中的字符串
NSString *html = @"<html><body> Some html string \n <font size=\"13\" color=\"red\">This is some text!</font> </body></html>";
    NSScanner *theScanner;
    NSString *text = nil;
    theScanner = [NSScanner scannerWithString:html];
    while ([theScanner isAtEnd] == NO) {
        [theScanner scanUpToString:@"<" intoString:NULL] ;
        [theScanner scanUpToString:@">" intoString:&text] ;
        html = [html stringByReplacingOccurrencesOfString:[NSString stringWithFormat:@"%@>", text] withString:@""];
    }
 
10. 修改占位文字上下居中
NSMutableParagraphStyle *style = [_textfield.defaultTextAttributes[NSParagraphStyleAttributeName] mutableCopy];
    
    style.minimumLineHeight = _textfield.font.lineHeight - (_textfield.font.lineHeight - [UIFont systemFontOfSize:12.0].lineHeight) / 2.0;
    
    _textfield.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@“占位文字内容” attributes:@{NSForegroundColorAttributeName: [UIColor lightGrayColor],NSFontAttributeName : [UIFont systemFontOfSize:12.0],NSParagraphStyleAttributeName : style}];
    [senderView addSubview:_textfield];
 
 
11.反编译友盟错误
dwarfdump --arch=arm64 --lookup 0x1008fe24c /Users/cf8_ios_01/Library/Developer/Xcode/Archives/2017-05-09/SimulationStocks\ 17-5-9\ 下午2.26.xcarchive/dSYMs/SimulationStocks.app.dSYM/Contents/Resources/DWARF/SimulationStocks
 
12. 控件在设置阴影的之前一定要先设置背景颜色   否则阴影效果显示不出来
 
13. 图片拉伸
image = [image resizableImageWithCapInsets:UIEdgeInsetsMake( 0, 7, 0, image.size.width-7) resizingMode:UIImageResizingModeStretch];
 
14. APP打开QQ对话框
NSString *qqNumber = @“QQ号”;
NSString *openQQUrl = [NSString stringWithFormat:@"mqq://im/chat?chat_type=wpa&uin=%@&version=1&src_type=web",qqNumber];
NSURL *url = [NSURL URLWithString:openQQUrl];
[[UIApplication sharedApplication] openURL:url];

猜你喜欢

转载自www.cnblogs.com/wangtutu/p/8926787.html