public
Created

Backgroundless UIPickerView (works with Autolayout on/off, ios 5/6 (ios7 untested))

  • Download Gist
BackgroundLessPickerView.h
Objective-C
1 2 3 4 5 6 7 8 9 10 11 12
//
// BackgroundLessPickerView.h
//
// Created by Barry Allard on 2013-08-27.
// Copyright (c) 2013 Barry Allard All rights reserved.
// License: MIT
 
#import <UIKit/UIKit.h>
 
@interface BackgroundLessPickerView : UIPickerView
 
@end
BackgroundLessPickerView.m
Objective-C
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
//
// BackgroundLessPickerView.m
//
// Created by Barry Allard on 2013-08-27.
// Copyright (c) 2013 Barry Allard All rights reserved.
// License: MIT
 
#import "BackgroundLessPickerView.h"
#import <QuartzCore/QuartzCore.h>
 
@implementation BackgroundLessPickerView
 
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
}
return self;
}
 
- (CALayer *)makeMask
{
CALayer* mask = [[CALayer alloc] init];
mask.backgroundColor = [UIColor blackColor].CGColor;
mask.frame = CGRectInset(self.bounds, 10.0f, 10.0f);
mask.cornerRadius = 5.0f;
return mask;
}
 
- (void)updateMask
{
self.layer.mask = [self makeMask];
}
 
- (void)layoutSubviews
{
[super layoutSubviews];
[self updateMask];
}
@end

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.