NSDate 格式和屏幕亮度

    技术2022-05-20  40

    dataFormat里设置类似"yyyy-MMM-dd"的格式日期格式如下:y  年  Year  1996; 96  M  年中的月份  Month  July; Jul; 07  w  年中的周数  Number  27  W  月份中的周数  Number  2  D  年中的天数  Number  189  d  月份中的天数  Number  10  F  月份中的星期  Number  2  E  星期中的天数  Text  Tuesday; Tue  a  Am/pm 标记  Text  PM  H  一天中的小时数(0-23)  Number  0  k  一天中的小时数(1-24)  Number  24  K  am/pm 中的小时数(0-11)  Number  0  h  am/pm 中的小时数(1-12)  Number  12  m  小时中的分钟数  Number  30  s  分钟中的秒数  Number  55  S  毫秒数  Number  978  z  时区  General time zone  Pacific Standard Time; PST; GMT-08:00  Z  时区  RFC 822 time zone  -0800

     

    判断系统是否为12小时制:

     

     

    -(BOOL)isAMPMSystemDate { BOOL flag = NO; NSDateFormatter *timeFormatter = [[NSDateFormatter alloc] init]; [timeFormatter setDateFormat:@"a"]; NSString *AMPMtext = [timeFormatter stringFromDate:[NSDate date]]; [timeFormatter release]; if ([AMPMtext isEqualToString:@""]){ NSLog(@"24小时制"); } else { NSLog(@"12小时制"); flag = YES; } return flag; }  

     

     

    调整屏幕亮度的解决方法,(非官方)

    读取屏幕亮度: 

      NSNumber *bl = (NSNumber*) CFPreferencesCopyAppValue(CFSTR("SBBacklightLevel" ), CFSTR("com.apple.springboard")); 

      previousBacklightLevel = [bl floatValue]; //a variable to store the previous level so you can reset it. 

      [bl release] 

      设置屏幕亮度: 

      GSEventSetBacklightLevel(newLevel); //The new level: 0.0 - 1.0. 

     

    注意,这个方法不会被审批。 

    一般都是设置view的透明度等颜色参数。


    最新回复(0)