[UIApplication sharedApplication].idleTimerDisabled = !lockscreenEnabled;
Monthly Archives: Май 2013
UIBarButtonItem
Кнопка в тулбаре/навбаре с красивой иконкой.
UIImage *faceImage = [UIImage imageNamed:(screenLocked) ? @"Locked" : @"Unlocked"];
UIButton *lockBt = [UIButton buttonWithType:UIButtonTypeCustom];
lockBt.bounds = CGRectMake(0, 0, faceImage.size.width, faceImage.size.height);
[lockBt setImage:faceImage forState:UIControlStateNormal];
[lockBt addTarget:self action:@selector(lockScreen:) forControlEvents:UIControlEventTouchUpInside];
lockButton = [[UIBarButtonItem alloc] initWithCustomView:lockBt];
Спрятать UITabBar программно
#import "UITabBarController+ShowHideBar.h"
@implementation UITabBarController (ShowHideBar)
- (void) setHidden:(BOOL)hidden{
CGRect screenRect = [[UIScreen mainScreen] bounds];
float fHeight = screenRect.size.height;
if( UIDeviceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation) ){
fHeight = screenRect.size.width;
}
if(!hidden) fHeight -= self.tabBar.frame.size.height;
[UIView animateWithDuration:0.25 animations:^{
for(UIView *view in self.view.subviews){
if([view isKindOfClass:[UITabBar class]]){
[view setFrame:CGRectMake(view.frame.origin.x, fHeight, view.frame.size.width, view.frame.size.height)];
}else{
if(hidden) [view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, fHeight)];
}
}
}completion:^(BOOL finished){
if(!hidden){
[UIView animateWithDuration:0.25 animations:^{
for(UIView *view in self.view.subviews)
{
if(![view isKindOfClass:[UITabBar class]])
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, fHeight)];
}
}];
}
}];
}
@end
UIAccessibilityIsInvertColorsEnabled
Удобная функция универсального доступа — инверсия цветов, для ночного чтения.
Проверить активность данного режима просто: UIAccessibilityIsInvertColorsEnabled, но вот программно активировать — API нет =(
Прийдется опять изобретать велосипед…
Проблема — отображение PDF в «ночном режиме» чтения (белое на чёрном).
Разрешить загрузку SVG файлов в WordPress
Добавить в functions.php:
function cc_mime_types( $mimes ){
$mimes['svg'] = 'image/svg+xml';
return $mimes;
}
add_filter( 'upload_mimes', 'cc_mime_types' );
Excel — полных лет от даты (возраст)
Простая формула:
=РАЗНДАТ(A1;СЕГОДНЯ();"Y")
Ячейка A1 — формат дата/время