-
-
Save riyanpratamap/984ed39ba3088eed40be85f0413f5e10 to your computer and use it in GitHub Desktop.
Simple CardView for iOS Objective-C
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <UIKit/UIKit.h> | |
@interface CardView : UIView | |
@end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "CardView.h" | |
static CGFloat radius = 2; | |
static int shadowOffsetWidth = 0; | |
static int shadowOffsetHeight = 3; | |
static float shadowOpacity = 0.5; | |
@implementation CardView | |
-(void)layoutSubviews{ | |
self.layer.cornerRadius = radius; | |
UIBezierPath *shadowPath = [UIBezierPath | |
bezierPathWithRoundedRect: self.bounds | |
cornerRadius: radius]; | |
self.layer.masksToBounds = false; | |
self.layer.shadowColor = [UIColor blackColor].CGColor; | |
self.layer.shadowOffset = CGSizeMake(shadowOffsetWidth, shadowOffsetHeight); | |
self.layer.shadowOpacity = shadowOpacity; | |
self.layer.shadowPath = shadowPath.CGPath; | |
} | |
-(id)initWithCoder:(NSCoder *)aDecoder{ | |
return [super initWithCoder:aDecoder]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment