Skip to content

Instantly share code, notes, and snippets.

View alekseypotapov-dev's full-sized avatar

Aleksey Potapov alekseypotapov-dev

View GitHub Profile
@alekseypotapov-dev
alekseypotapov-dev / AppDelegate+Blur.m
Last active April 18, 2021 10:03
Blurring sensitive data
#pragma mark - Security
- (void)applicationDidEnterBackground:(UIApplication *)application {
RootViewController *rootVC = (RootViewController *)self.window.rootViewController;
UIViewController *viewController = (UIViewController *)[rootVC.presentedViewControllers lastObject];
/**
If the last presented view controller is a SplashViewController we must not present the splash
screen again.
*/
if (![viewController isKindOfClass:[SplashViewController class]]) {
/**
@alekseypotapov-dev
alekseypotapov-dev / Constants
Last active August 21, 2017 13:02
Handy #define's
#define IS_IPHONE_5 ( fabs( ( double )[ [ UIScreen mainScreen ] bounds ].size.height - ( double )568 ) < DBL_EPSILON )
//get ios verison
[[[UIDevice currentDevice] systemVersion] floatValue]
#define isIPAD UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad
// Logging
// DLog will output like NSLog only when the DEBUG variable is set
@alekseypotapov-dev
alekseypotapov-dev / CustomSegmentedControl.m
Created February 27, 2014 09:05
Make possibility to react segment on continious tap and stay highlighted in custom UISegmentedControl
+ (BOOL)isIOS7
{
static BOOL isIOS7 = NO;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
NSInteger deviceSystemMajorVersion = [[[[[UIDevice currentDevice] systemVersion] componentsSeparatedByString:@"."] objectAtIndex:0] integerValue];
if (deviceSystemMajorVersion >= 7) {
isIOS7 = YES;
}
else {
@alekseypotapov-dev
alekseypotapov-dev / PlistReader.m
Last active August 29, 2015 13:56
Use this if you wonna to save .plist to Document directory and then wonna to edit this file
/*
Then just to use somehow like this (if array)
NSMutableArray *parsedPlist = [[NSMutableArray alloc] initWithContentsOfFile:[PlistReader copyFileToDocumentDirectory:%"filename.plist"]];
*/
+ (NSString *)copyFileToDocumentDirectory:(NSString *)fileName
{
NSError *error;
@alekseypotapov-dev
alekseypotapov-dev / UISegmentedControlSegmentPopover
Created February 27, 2014 08:45
UISegmentedControl show popover from according segment
CGRect frame = [segmentControl frame];
frame =CGRectMake((frame.size.width/No. of segments * [segmentControl selectedSegmentIndex]), 0, frame.size.width/No. of segments, segmentControl.bounds.size.height);
[m_PopOver presentPopoverFromRect:frame inView:segmentControl permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];