Jtapplecalendar: 2 Date Segment on 1 UIView

Created on 28 Jul 2016  Â·  6Comments  Â·  Source: patchthecode/JTAppleCalendar

Hi, can I show 2 segment using JTAppleCalendar? I mean, on a UIViewController, I would like to have 2 months displayed vertically instead of only 1.. Please see image below.

image

Thank you.

question

Most helpful comment

@mrjimoy

1) _How to show the day name above the date?_

Are you trying to make your calendar look like the image you just provided above? If yes, then you can do exactly what @mecid said.

Simply create a header.xib file and design it like this:

screen shot 2016-07-29 at 9 45 13 am

You can look at the example code attached to this project to see how to create a header view. You can also checkout this wiki question

2) _Is it possible to create the multiple selection as a range_

Although I do not have this feature built in, the calendar is flexible enough that you can build it your self as can be seen here. It does not take much code to build it, but I will be implementing this as a feature in the library soon.

All 6 comments

Let me know if this works for you.

Hi @patchthecode, thank you so much. It's worked with some adjustment on the measurement. I have another questions:

  1. How to show the day name above the date? Do we need to create a separate XIB (HeaderViewCell) or is there any function that can directly show the day name?
  2. Is it possible to create the multiple selection as a range (like attached image below)? I think this one is related to https://github.com/patchthecode/JTAppleCalendar/issues/54, I tried to do some changes on the code but got stuck.

image

Thanks.

@mrjimoy You need to create separate XIB or add View like this.

class WeekdaysView: UIStackView {
    private lazy var weekdayLabels: [UILabel] = self.createWeekdayLabels()

    private func createWeekdayLabels() -> [UILabel] {
        let formatter = NSDateFormatter()
        var weekdayLabels = [UILabel]()

        for i in 0...6 {
            let label = UILabel(frame: CGRectZero)
            label.font = UIFont.preferredFontForTextStyle(UIFontTextStyleCaption2)
            label.text = formatter.veryShortWeekdaySymbols[i]
            label.textColor = UIColor.lightTextColor()
            label.textAlignment = .Center

            weekdayLabels.append(label)
        }

        return weekdayLabels
    }

    override init(frame: CGRect) {
        super.init(frame: frame)
        setup()
    }

    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
    }

    override func awakeFromNib() {
        super.awakeFromNib()
        setup()
    }

    private func setup() {
        self.axis = .Horizontal
        self.alignment = .Center
        self.distribution = .FillEqually

        for label in weekdayLabels {
            addArrangedSubview(label)
        }
    }
}

@mrjimoy

1) _How to show the day name above the date?_

Are you trying to make your calendar look like the image you just provided above? If yes, then you can do exactly what @mecid said.

Simply create a header.xib file and design it like this:

screen shot 2016-07-29 at 9 45 13 am

You can look at the example code attached to this project to see how to create a header view. You can also checkout this wiki question

2) _Is it possible to create the multiple selection as a range_

Although I do not have this feature built in, the calendar is flexible enough that you can build it your self as can be seen here. It does not take much code to build it, but I will be implementing this as a feature in the library soon.

i'll close this issue. If you have any other questions please as it on another thread. This thread is now becoming more than one topic.

Great, thank you so much @patchthecode :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

PedroAnibarro1 picture PedroAnibarro1  Â·  5Comments

Fatalution picture Fatalution  Â·  3Comments

Geekbell picture Geekbell  Â·  4Comments

MoridinBG picture MoridinBG  Â·  5Comments

dbmrq picture dbmrq  Â·  5Comments