-
-
Save Zumbalamambo/54acbc353046f363c197c3bd5c05f86b to your computer and use it in GitHub Desktop.
iOS view that looks like CardView from Android
This file contains 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> | |
//Based on: https://github.com/aclissold/CardView | |
@interface CardView : UIView | |
@end |
This file contains 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" | |
@implementation CardView | |
- (void)layoutSubviews | |
{ | |
[super layoutSubviews]; | |
float cornerRadius = 2; | |
int shadowOffsetWidth = 0; | |
int shadowOffsetHeight = 3; | |
float shadowOpacity = 0.5; | |
UIColor* shadowColor = [UIColor blackColor]; | |
UIBezierPath* shadowPath = [UIBezierPath bezierPathWithRoundedRect:self.bounds cornerRadius:cornerRadius]; | |
self.backgroundColor = [UIColor blueColor]; // TODO change color | |
self.layer.cornerRadius = cornerRadius; | |
self.layer.masksToBounds = false; | |
self.layer.shadowColor = shadowColor.CGColor; | |
self.layer.shadowOffset = CGSizeMake(shadowOffsetWidth, shadowOffsetHeight); | |
self.layer.shadowOpacity = shadowOpacity; | |
self.layer.shadowPath = shadowPath.CGPath; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment