美文网首页
iOS开发中的经验之二

iOS开发中的经验之二

作者: 懒惰的习惯 | 来源:发表于2016-01-09 16:11 被阅读95次

    1、护眼色:RGB(199,237,204)【#C7EDCC】
    类的颜色为:70,97,127

    2、//NSDate对象的基本常识
    now (当前时间点)
    相对于1 January 2001, GMT的时间点
    相对于1970的时间点
    distantFuture (不可达到的未来的某个时间点) distantPast (不可达到的 过去的某个时间点

    3、// 相对于已知的某个时间点

          - (id) initWithTimeInterval:(NSTimeInterval) secsToBeAdded
    sinceDate:(NSDate *) anotherDate;       
          // 相对于当前时间
          - (id) initWithTimeIntervalSinceNow:(NSTimeInterval) secsToBeAdded;      
          // 相对于1970年1月1日0时0分0秒
          - (id) initWithTimeIntervalSince1970:(NSTimeInterval)seconds;        
          // 相对于2001年1月1日0时0分0秒
           - (id) initWithTimeIntervalSinceReferenceDate:(NSTimeInterval) secs;      
    
          
    
    // iOS中NSDate最常用的方法:
    <!-- lang: cpp -->
    NSDate *now = [NSDate date];    // [[NSDate alloc] init]
    NSDate *dateFromNow = [NSDate dateWithTimeIntervalSinceNow:60];
    NSDate *dateFromAnotherDate = [[NSDate alloc] initWithTimeInterval:60 sinceDate:dateFromNow];
    
    NSTimeInterval timeInterval1 = [now timeIntervalSinceDate:dateFromNow];
    NSTimeInterval timeInterval2 = [now timeIntervalSinceNow];
    
    //-------------------------------------------------------------
    NSDate *distantPast = [NSDate distantPast];          //  可以表示的最早的时间
    NSDate *distantFuture = [NSDate distantFuture];      //  可以表示的最远的未来时间
    
    NSString *stringDate = @"12/31/9999";
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]init];
    [dateFormatter setDateFormat:@"MM/dd/yyyy"];
    NSDate *dateCheck = [dateFormatter dateFromString:stringDate];
    NSLog(@"Date = %@", dateCheck);
    
    Output:
    Date = 1999-12-30 16:00:00 +0000
    
    *iOS中用NSDate表示的时间只能在distantPast和distantFuture之间!
    //-------------------------------------------------------------
    

    4、//NSCalendar NSDateComponents的那点事
    http://my.oschina.net/yongbin45/blog/156181

    5、place这个app跟我们的很像,很多动能都可以借鉴一下

    6、// UIImage这个图像在旋转的时候,其实其真实图像还是UIImageOrientationUp时的图像,因此在更改图像角度的时候不是叠加旋转,比如说,我第一次UIImageOrientationUp了,第二次UIImageOrientationUp还是原图,实际上根本就没有变,因此,我是采用的一下方法:
    if (_imageTation == UIImageOrientationRight) {
    _imageTation = UIImageOrientationDownMirrored;
    } else if (_imageTation == UIImageOrientationDownMirrored) {
    _imageTation = UIImageOrientationLeft;
    } else if (_imageTation == UIImageOrientationLeft){
    _imageTation = UIImageOrientationUp;
    } else {
    _imageTation = UIImageOrientationRight;
    }
    通过更改每次旋转值的不同,而旋转的角度不同实现功能的。

    7、// 在类(+)方法中实现图片的一些操作和功能时,我地时间想到的是先实例化[[A alloc] init]再去调用类里面的其他方法,其实不然,当我们不需要这个类的对象时,我们可以直接调用类方法,通过[[self alloc] init]或者是直接[[self alloc] initWithA:A]就可以了,无需考虑对象。

    相关文章

      网友评论

          本文标题:iOS开发中的经验之二

          本文链接:https://www.haomeiwen.com/subject/pmafkttx.html