干货知识分子iOS CoreAnimation

iOS Tips(无限期更新...)

2015-12-27  本文已影响555人  Lonely__M
 UIEdgeInsetsMake 的top bottom left right 必须是对称的比如5,-5
exp:
vc.tabBarItem.imageInsets = UIEdgeInsetsMake(5, 0, -5, 0);  (显示正常)
vc.tabBarItem.imageInsets = UIEdgeInsetsMake(5, 0, -4, 0); (每次点击 item 会变小)
 //显示多行,自适应高度
    UILabel *label3 = [[UILabelalloc] initWithFrame:CGRectZero];
    [self.viewaddSubview:label3];
    label3.backgroundColor =[UIColorredColor];
    label3.text =@"测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试!";

/* // Support for constraint-based layout (auto layout)
// If nonzero, this is used when determining -intrinsicContentSize for multiline labels

@property(nonatomic) CGFloat preferredMaxLayoutWidth NS_AVAILABLE_IOS(6_0); 

*/
    label3.preferredMaxLayoutWidth = (self.view.frame.size.width -10.0 * 2);
    label3.numberOfLines =0;
    [label3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10.0);
        make.right.mas_equalTo(-10.0);
        make.top.mas_equalTo(100.0);
    }];
http://itunes.apple.com/cn/lookup?id=#appid#  
注意 appid 替换成 自己App的id
/** 改变webView 阻尼系数 */
 _webView.scrollView.decelerationRate = UIScrollViewDecelerationRateNormal;
Deployment 为 iOS 7.0 打包出来的ipa中 Assets.car 文件 大约比 Deployment 为 iOS 8.0 打包出来的ipa中 Assets.car 小一半左右  Deployment 为 iOS 9.0 打包出来的Assets.car 文件和 7.0 下差不多 
 UIImageView *imageView = [[UIImageView alloc] initWithFrame:self.view.bounds];
    imageView.image = [UIImage imageNamed:@"index"];
    [self.view addSubview:imageView];
    
     /** 在希望模糊的view上加一个 toolBar 即可 */
    UIToolbar *toolBar = [[UIToolbar alloc] initWithFrame:imageView.frame];
    [imageView addSubview:toolBar];
    
#pragma mark 数组排序4-高级排序  
void arraySort4() {  
    Student *stu1 = [Student studentWithFirstname:@"MingJie" lastname:@"Li" bookName:@"book1"];  
    Student *stu2 = [Student studentWithFirstname:@"LongHu" lastname:@"Huang" bookName:@"book2"];  
    Student *stu3 = [Student studentWithFirstname:@"LianJie" lastname:@"Li" bookName:@"book2"];  
    Student *stu4 = [Student studentWithFirstname:@"Jian" lastname:@"Xiao" bookName:@"book1"];  
    NSArray *array = [NSArray arrayWithObjects:stu1,stu2,stu3, stu4, nil nil];  
      
    // 1.先按照书名进行排序  
    // 这里的key写的是@property的名称  
    NSSortDescriptor *bookNameDesc = [NSSortDescriptor sortDescriptorWithKey:@"book.name" ascending:YES];  
    // 2.再按照姓进行排序  
    NSSortDescriptor *lastnameDesc = [NSSortDescriptor sortDescriptorWithKey:@"lastname" ascending:YES];  
    // 3.再按照名进行排序  
    NSSortDescriptor *firstnameDesc = [NSSortDescriptor sortDescriptorWithKey:@"firstname" ascending:YES];  
    // 按顺序添加排序描述器  
    NSArray *descs = [NSArray arrayWithObjects:bookNameDesc, lastnameDesc, firstnameDesc, nil nil];  
      
    NSArray *array2 = [array sortedArrayUsingDescriptors:descs];  
      
    NSLog(@"array2:%@", array2);  
}  

    NSString * html = @"<html><body><style>body{background-color:#FFFFFF;color:#555555;}img {max-width:200px;max-height:200px;}</style> <p><img src=http://tp.mnks.cn/tp_105.jpg></p>Some<input type='text' size='5'> <br/>html <strong>string</strong> <b>hdhs</b><i>d</i> </body></html>";
    
    NSAttributedString *attr = [[NSAttributedString alloc] initWithData:[html dataUsingEncoding:NSUnicodeStringEncoding] options:@{NSDocumentTypeDocumentAttribute:NSHTMLTextDocumentType} documentAttributes:nil error:nil];
    
    lable.attributedText = attr;
class ControversyManager {
    static let sharedInstance = ControversyManager()
}
[[UIApplication sharedApplication].windows firstObject].rootViewController
-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{
    ///配置 CATransform3D 动画内容
    CATransform3D  transform ;
    transform.m34 = 1.0/-800;
    //定义 Cell的初始化状态
    cell.layer.transform = transform;
    //定义Cell 最终状态 并且提交动画
    [UIView beginAnimations:@"transform" context:NULL];
    [UIView setAnimationDuration:1];
    cell.layer.transform = CATransform3DIdentity;
    cell.frame = CGRectMake(0, cell.frame.origin.y, cell.frame.size.width, cell.frame.size.height);
    [UIView commitAnimations];
    
}
// 文字图片拼接显示
- (void)setLabel3
{
    // NSTextAttachment - 附件
    // 1.创建文本附件包含图片,知道附件 bounds
    NSTextAttachment *attachMent = [[NSTextAttachment alloc] init];
    
    // 设置图片
    attachMent.image = [UIImage imageNamed: @"image"];
    
    // 设置大小
    CGFloat height = self.label.font.lineHeight;
    attachMent.bounds = CGRectMake(0, 0, height, height);
    
    // 添加
    // 2.使用附件创建属性字符串
    NSAttributedString *attrString = [NSAttributedString attributedStringWithAttachment:attachMent];
    
    // 拼接文字
    NSString *str = @"测试";
    // 3.创建可变字符 拼接字符串
    NSMutableAttributedString *strM = [[NSMutableAttributedString alloc] initWithString:str];
    [strM appendAttributedString:attrString];
    [strM appendAttributedString: [[NSAttributedString alloc] initWithString: @"测试"]];
    
    // 设置 label 内容
    self.label.backgroundColor = [UIColor grayColor];
    self.label.attributedText = strM;
}
:在plist文件中将 View controller-based status bar appearance 设置为NO 在application:didFinishLaunchingWithOptions:中添加下面代码 
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];
 [[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationNone];
显示UIMenuController前必须调用becomeFirstResponder 例如  [self.view becomeFirstResponder];
必须重写canBecomeFirstResponder方法返回YES
有些控件会有系统的UIMenuItem,使用canPerformAction:withSender:方法筛选出需要的item

Tip


学习的路上总是曲折的,每个人都是从菜鸟过来的,遇到问题总是希望能够与他人沟通交流,而在各种群里问了问题就石沉大海,所以想建一个技术交流为主的群,遇到的问题可以记录下来分享给他人,方便了自己,也造就了他人,不管怎样,记录点滴,但愿与君共勉

*QQ群号:527377492 *

Paste_Image.png
上一篇下一篇

猜你喜欢

热点阅读