Hide Keyboard when tap return in textview


- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text {
    
    if([text isEqualToString:@"\n"]) {
        [textView resignFirstResponder];
        return NO;
    }
    
    return YES;
}

Tap anywhere to hide Keyboard


- (void)viewDidLoad
{
    [super viewDidLoad];
    self.singleTapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(didTapAnywhere:)];
    self.singleTapRecognizer.numberOfTapsRequired = 1;
    self.singleTapRecognizer.cancelsTouchesInView = NO;
}

-(void)didTapAnywhere: (UITapGestureRecognizer*) recognizer {    
    //[textField resignFirstResponder];
    [self.view endEditing:YES];
}

- (void)textViewDidBeginEditing:(UITextView *)textView
{
    NSLog(@"add gesture recg");
    [self.view addGestureRecognizer:singleTapRecognizer];
}
- (void)textViewDidEndEditing:(UITextView *)textView
{
    NSLog(@"remove gesture recg");
    [self.view removeGestureRecognizer:singleTapRecognizer];
}

Stretching an UIImage while preserving the corners




 original image


 result














myImageView.image = [myImageView.image resizableImageWithCapInsets:UIEdgeInsetsMake(20.f, 12.f, 19.f, 19.f)];


For lower iOS version, use 

[UIImage stretchableImageWithLeftCapWidth:15 topCapHeight:13];

Blur Effect

Add QuartzCore Framework
Add this to the beginning of the AppDelegates.h


#import <QuartzCore/QuartzCore.h>

@interface CAFilter : NSObject 
@end

Add this to the didFinishLaunchingWithOptions method (before makeKeyAndVisible call)


CAFilter* filter = [CAFilter filterWithName:@"gaussianBlur"];
[filter setValue:[NSNumber numberWithFloat:5] forKey:@"inputRadius"];
window.layer.filters = [NSArray arrayWithObject:filter];

Other way you can use this in UIView:

- (IBAction)toggleBlur {
    CALayer *layer = [self.blurView layer];
    blur = !blur;
    if (blur) {
        [layer setRasterizationScale:0.3];
        [layer setShouldRasterize:YES];
    } else {
        [layer setRasterizationScale:1.0];
        [layer setShouldRasterize:NO];
    }
}


See the other static filters available at: