Skip to content

Instantly share code, notes, and snippets.

@Antarix
Last active January 7, 2020 12:11
Show Gist options
  • Save Antarix/41826addb99d71851742 to your computer and use it in GitHub Desktop.
Save Antarix/41826addb99d71851742 to your computer and use it in GitHub Desktop.
Simple CardView for iOS Objective-C
#import <UIKit/UIKit.h>
@interface CardView : UIView
@end
#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