Skip to content

Instantly share code, notes, and snippets.

View obyknovenius's full-sized avatar

Vitaly Dyachkov obyknovenius

  • Cologne, Germany
  • 03:28 (UTC +02:00)
View GitHub Profile
- (NSString *)description
{
return [NSString stringWithFormat:@"<%@: %p, data=%@>",
NSStringFromClass([self class]), self, [self data]];
}
@obyknovenius
obyknovenius / segue_popover.m
Last active August 29, 2015 13:57
Dismiss a Storyboard Popover
@interface ViewController ()
@property (nonatomic, strong) ReaderIssueView *issueView;
@end
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
self.thePopover = [(UIStoryboardPopoverSegue *)segue popoverController];
}
#pragma mark - Application's Documents directory
- (NSURL *)applicationDocumentsDirectory
{
return [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject];
}
@obyknovenius
obyknovenius / convert-alpha.sh
Last active August 29, 2015 14:00
Convert alpha to opaque and vice versa.
convert origin.png -background black -alpha background -channel a -negate +channel converted.png
@obyknovenius
obyknovenius / modal-view-controller-size.m
Created May 16, 2014 13:04
Custom size of modal view controller on iPad.
- (void)viewWillLayoutSubviews
{
[super viewWillLayoutSubviews];
self.view.superview.bounds = CGRectMake(0, 0, 100.0f, 100.0f);
[[self.view.superview layer] setCornerRadius:5.0f];
[[self.view.superview layer] setMasksToBounds:YES];
}
@obyknovenius
obyknovenius / show-hide-keyboard.m
Last active August 29, 2015 14:01
Move view up when the keyboard appears.
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillShown:)
name:UIKeyboardWillShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillBeHidden:)
- (void)viewDidLoad
{
[super viewDidLoad];
UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark];
UIVisualEffectView *blurView = [[UIVisualEffectView alloc] initWithEffect:blurEffect];
UIVibrancyEffect *vibrancyEffect = [UIVibrancyEffect effectForBlurEffect:blurEffect];
UIVisualEffectView *vibrancyView = [[UIVisualEffectView alloc] initWithEffect:vibrancyEffect];
#import "UIResponder+FirstResponder.h"
static __weak id currentFirstResponder;
@implementation UIResponder (FirstResponder)
+ (id)currentFirstResponder
{
currentFirstResponder = nil;
[[UIApplication sharedApplication] sendAction:@selector(findFirstResponder:) to:nil from:nil forEvent:nil];
@interface Person
@property NSString *name;
@property NSDate *birthday;
- (BOOL)isEqualToPerson:(Person *)person;
@end
@implementation Person
- (BOOL)isEqualToPerson:(Person *)person {
#import "LoginSegue.h"
@implementation LoginSegue
- (void)perform
{
UIViewController *sourceViewController = self.sourceViewController;
UIViewController *destinationViewController = self.destinationViewController;
UIWindow *window = [[[UIApplication sharedApplication] delegate] window];