Last active
July 11, 2019 13:14
-
-
Save gelldur/8e9d2586478eb9319ec5d9f21b517aa4 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