1、如果要设置视图的阴影效果,我们必须不能设置以下代码
view.layer.masksToBounds = YES
2、自定义导航栏解决边缘手势返回失效
self.navigationController.interactivePopGestureRecognizer.delegate = (id)self;
3、将时间转化为时间戳
//将时间转化为时间戳
+ (NSString*)timeWithTimeIntervalString:(NSString*)timeString
{
NSString* timeStr = timeString;
NSDateFormatter*formatter = [[NSDateFormatteralloc]init];
//设置你想要的格式,hh与HH的区别:分别表示12小时制,24小时制
[formattersetDateFormat:@"YYYY-MM-dd"];
// UTC是设置北京时间
NSTimeZone* timeZone = [NSTimeZonetimeZoneWithName:@"UTC"];
[formattersetTimeZone:timeZone];
//将字符串按formatter转成nsdate
NSDate* date = [formatterdateFromString:timeStr];
//时间转时间戳的方法:
NSString*timeSp = [NSStringstringWithFormat:@"%ld", (long)[datetimeIntervalSince1970]];
returntimeSp;
}
4、date转化为string
+ (NSString*)dateConversionStringWithDate:(NSDate*)date dateFormat:(NSString*)dateFormat
{
NSDateFormatter*format = [[NSDateFormatteralloc]init];
format.dateFormat= dateFormat;
NSString*string = [formatstringFromDate:date];
returnstring;
}
5、返回当前对应的星期
+ (NSString*)stringForDateWeek
{
NSArray*weekdays = [NSArrayarrayWithObjects: [NSNullnull],
@"Sunday",
@"星期一",@"星期二",@"星期三",@"星期四",@"星期五",@"星期六",nil];
NSDate*nowDate = [NSDatedate];
NSCalendar*calendar = [NSCalendarcurrentCalendar];
NSDateComponents*comp = [calendarcomponents:NSCalendarUnitYear|NSCalendarUnitMonth|NSCalendarUnitDay|NSCalendarUnitWeekday|NSCalendarUnitDayfromDate:nowDate];
//获取今天是周几
NSIntegerweekDay = [compweekday];
return[weekdaysobjectAtIndex:weekDay];
}
今天暂时就写这么多,之后有时间接着更新。
网友评论