Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to hide the column and row separator in FSCalendar #499

Closed
mathupriyakannan opened this issue Nov 25, 2016 · 5 comments
Closed

How to hide the column and row separator in FSCalendar #499

mathupriyakannan opened this issue Nov 25, 2016 · 5 comments

Comments

@mathupriyakannan
Copy link

The following informations are requested in a bug report

  • A brief bug description.
  • Stack trace.
  • Integration method.(manually/cocoapods/carthage)
  • Full steps to reproduce.
  • Device modal and iOS version. e.g. iPhone 6s iOS9.1
  • Xcode version. e.g. Xcode 8.1
  • FSCalendar version. e.g. FSCalenda 2.5.1
  • Does this happen in the demo project? Which one? Or a link to another demo project.

如果在使用过程中遇到问题,请提供以下信息以便于尽快将问题修复

  • 简单描述一下问题。
  • 控制台输出的堆栈跟踪(如果有的话)。
  • 安装方式. 如手动安装、cocoapods安装、或者通过carthage安装
  • 能够重现此问题的完整步骤。
  • 设备型号及版本。 例如: iPhone6s iOS9.1
  • 使用的Xcode版本。 例如: Xcode8.1
  • FSCalendar版本. 例如: FSCalendar 2.5.1
  • 是否能在demo中重现,以及在哪个demo中重现?或者附加一个重现问题的demo链接。
@mathupriyakannan
Copy link
Author

mathupriyakannan commented Nov 25, 2016

Hi ,
How can I hide the column and row separator in the DIV Example ?
Please advise .

@WenchaoD
Copy link
Owner

Hi @mathupriyakannan . The insets between each columns and rows are actually bogus. To remove it, just erase everything in DIVCalendarCell about backgroundView.

@mathupriyakannan
Copy link
Author

mathupriyakannan commented Nov 28, 2016

Hi WenchaoD ,
Thanks for your response .
As per your suggestion , I had commented backgroundView and separator are hidden .But while I am selecting the date range they are visible , how I need to hide the separator while the date range are selected ? Please find the below code ,
------------------------------- #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 colorWithRed:(0.0/255.0) green:(102.0/255.0) blue:(204.0/255.0) alpha:0.75].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 = CGRectInset(self.bounds, 1, 0.5);
    //self.circleImageView.frame = self.backgroundView.frame;

    self.selectionLayer.frame = CGRectInset(self.bounds, -1, 0);

    if (self.selectionType == SelectionTypeMiddle) {

      self.selectionLayer.path = [UIBezierPath bezierPathWithRect:self.selectionLayer.bounds].CGPath;
    

    } else if (self.selectionType == SelectionTypeLeftBorder) {

      self.selectionLayer.path = [UIBezierPath bezierPathWithRoundedRect:self.selectionLayer.bounds byRoundingCorners:UIRectCornerTopLeft|UIRectCornerBottomLeft cornerRadii:CGSizeMake(self.selectionLayer.fs_width/2, self.selectionLayer.fs_width/2)].CGPath;
    

    } else if (self.selectionType == SelectionTypeRightBorder) {

      self.selectionLayer.path = [UIBezierPath bezierPathWithRoundedRect:self.selectionLayer.bounds byRoundingCorners:UIRectCornerTopRight|UIRectCornerBottomRight cornerRadii:CGSizeMake(self.selectionLayer.fs_width/2, self.selectionLayer.fs_width/2)].CGPath;
    

    } else if (self.selectionType == SelectionTypeSingle) {

      CGFloat diameter = MIN(self.selectionLayer.fs_height, self.selectionLayer.fs_width);
      self.selectionLayer.path = [UIBezierPath bezierPathWithOvalInRect:CGRectMake(self.contentView.fs_width/2-diameter/2, self.contentView.fs_height/2-diameter/2, diameter, diameter)].CGPath;
    

    }
    }

  • (void)setSelectionType:(SelectionType)selectionType
    {
    if (_selectionType != selectionType) {
    _selectionType = selectionType;
    [self setNeedsLayout];
    }
    }

@EnD
Please find the below screenshot ,

image
In the older code DIVCalendarCell:

#import "DIVCalendarCell.h"

@implementation DIVCalendarCell

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.

  • (void)drawRect:(CGRect)rect {
    // Drawing code
    }
    */

  • (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 colorWithRed:(0.0/255.0) green:(102.0/255.0) blue:(204.0/255.0) alpha:0.75].CGColor;
     // selectionLayer.fillColor = [UIColor yellowColor].CGColor;
      [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 colorWithRed:(29.0/255.0) green:(123.0/255.0) blue:(192.0/255.0) alpha:0.75] colorWithAlphaComponent:0.1];
      // self.backgroundColor = [UIColor colorWithRed:(29.0/255.0) green:(123.0/255.0) blue:(192.0/255.0) alpha:0.75] ;
      //
    

    }
    return self;
    }

  • (void)layoutSubviews
    {
    [super layoutSubviews];

    //self.backgroundView.frame = CGRectInset(self.bounds, 0, 0);
    self.circleImageView.frame = CGRectInset(self.bounds, 1, 0.5);

    self.selectionLayer.frame = CGRectInset(self.bounds, -1, 0);
    }

@EnD
I need the separator to be hidden while the date range are selected in calendar. Please advise . Thanks, Mathu Priya

@WenchaoD
Copy link
Owner

@mathupriyakannan There is a small 0.5 pixel gap between some of the cells. And this line self.selectionLayer.frame = CGRectInset(self.bounds, -1, 0); make the selectionLayer intersect each other. To solve this problem, you can replace the color of selectionLayer with one without an alpha channel.

@mathupriyakannan
Copy link
Author

Thank you :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants