日常随笔

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];
 
15. 去掉导航栏下面的线

  [self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];

    [self.navigationController.navigationBar setShadowImage:[UIImage new]];

转载于:https://www.cnblogs.com/wangtutu/p/8926787.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值