FSCalendar/Example-Objc/DIYCalendarCell.m

48 lines
1.4 KiB
Objective-C

//
// DIYCalendarCell.m
// FSCalendar
//
// Created by dingwenchao on 02/11/2016.
// Copyright © 2016 wenchaoios. All rights reserved.
//
#import "DIYCalendarCell.h"
#import "FSCalendarExtensions.h"
@implementation DIYCalendarCell
- (instancetype)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
UIImageView *circleImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"circle"]];
[self.contentView insertSubview:circleImageView atIndex:0];
self.circleImageView = circleImageView;
CAShapeLayer *selectionLayer = [[CAShapeLayer alloc] init];
selectionLayer.fillColor = [UIColor blackColor].CGColor;
selectionLayer.actions = @{@"hidden":[NSNull null]};
[self.contentView.layer insertSublayer:selectionLayer below:self.titleLabel.layer];
self.selectionLayer = selectionLayer;
self.shapeLayer.hidden = YES;
self.backgroundView = [[UIView alloc] initWithFrame:self.bounds];
self.backgroundView.backgroundColor = [[UIColor lightGrayColor] colorWithAlphaComponent:0.1];
}
return self;
}
- (void)layoutSubviews
{
[super layoutSubviews];
self.backgroundView.frame = CGRectInset(self.bounds, 1, 0.5);
self.circleImageView.frame = self.backgroundView.frame;
self.selectionLayer.frame = CGRectInset(self.bounds, -1, 0);
}
@end