iOS开源 - 日历组件

mg6247 5年前
   <h2><strong>Koyomi</strong></h2>    <p>Koyomiis a simple calender view framework for iOS, written in Swift :calendar:</p>    <p style="text-align: center;"><img src=""></p>    <h2><img src=""><strong> Features</strong></h2>    <ul>     <li>Simple Calender View :calendar:</li>     <li>Easily usable :sunglasses:</li>     <li>Customizable in any properties for appearance</li>     <li>Support @IBDesignable and @IBInspectable</li>     <li>Support Swift 2.3</li>     <li>Support Swift 3.0</li>    </ul>    <h2><strong>Demo App</strong></h2>    <p>Open Example/Koyomi.xcworkspace and run Koyomi-Example to see a simple demonstration.</p>    <h2><strong>Usage</strong></h2>    <p><em>Koyomi</em> is designed to be easy to use :sunglasses:</p>    <p style="text-align: center;"><img src=""></p>    <pre>  let frame = CGRect(x: 10, y : 20, width: 250, height: 300)      let koyomi = Koyomi(frame: frame, sectionSpace: 1.5, cellSpace: 0.5, inset: UIEdgeInsetsZero, weekCellHeight: 25)      view.addSubview(koyomi)</pre>    <p>Koyomi is available in Interface Builder. Set custom class of UICollectionView to Koyomi</p>    <pre>  @IBOutlet weak var koyomi: Koyomi!</pre>    <h3><strong>:calendar: Change displayed month</strong></h3>    <p>If you want to change displayed month, call display(in: MonthType) . MonthType is defined by three types.</p>    <pre>  public enum MonthType { case previous, current, next }        // change month      koyomi.display(in: .next)</pre>    <h3><strong>Get current month string</strong></h3>    <pre>  let currentDateString = koyomi.currentDateString(withFormat: "M/yyyy")</pre>    <h3><strong>The selection state of date</strong></h3>    <p>You can select specific date.</p>    <pre>  let today = NSDate()      let components = NSDateComponents() = 7      let weekLaterDay = NSCalendar.currentCalendar().dateByAddingComponents(components, toDate: today, options: NSCalendarOptions(rawValue: 0)) NSDate(), to: weekLaterDay)        // If want to select only one day, call today)</pre>    <p style="text-align: center;"><img src=""></p>    <p>You can also unselect available.</p>    <pre>  koyomi.unselect(NSDate(), to: weekLaterDay) // or koyomi.unselect(NSDate())        // unselect all date      koyomi.unselectAll()</pre>    <p>You can configure day color in selected state.</p>    <pre>  // Support @IBInspectable      @IBInspectable public var selectedBackgroundColor: UIColor      @IBInspectable public var selectedTextColor: UIColor</pre>    <h2><strong>KoyomiDelegate</strong></h2>    <p>If you want to use KoyomiDelegate , set calenderDelegate to target</p>    <pre>  koyomi.calenderDelegate = self</pre>    <p>Return the date user selected, when tapped cell</p>    <pre>  optional func koyomi(koyomi: Koyomi, didSelect date: NSDate, forItemAt indexPath: NSIndexPath)</pre>    <p>Return the current month string, when changed month.</p>    <pre>  optional func koyomi(koyomi: Koyomi, currentDateString dateString: String)        // if you want to change string format, use `currentDateFormat`      koyomi.currentDateFormat = "M/yyyy"</pre>    <h2><strong>:wrench: Customize Koyomi</strong></h2>    <h3><strong>Customize layout</strong></h3>    <pre>  // Support @IBInspectable      @IBInspectable var sectionSpace: CGFloa      @IBInspectable var cellSpace: CGFloat      @IBInspectable var weekCellHeight: CGFloat      // Public method      public var inset: UIEdgeInsets</pre>    <p><img src=""></p>    <pre>  koyomi.inset = UIEdgeInsets(top: 0.5, left: 0.5, bottom: 0.5, right: 0.5)</pre>    <p>Set sectionSpace , cellSpace , weekCellHeight in initialization or Interface Builder.</p>    <h3><strong>Customize text font</strong></h3>    <pre>  // set Day and Week Label Font      koyomi          .setDayFont(size: 12)           .setWeekFont(size: 8)        // if want to change font name, use:       // setDayFont(fontName: ".SFUIText-Medium", size: 12)</pre>    <h3><strong>Customize weeks text</strong></h3>    <pre>  koyomi.weeks = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]</pre>    <h2><strong>Customize color</strong></h2>    <pre>  // Support @IBInspectable      @IBInspectable public var sectionSeparatorColor: UIColor      @IBInspectable public var separatorColor: UIColor      @IBInspectable public var weekColor: UIColor      @IBInspectable public var weekdayColor: UIColor      @IBInspectable public var holidayColor: UIColor      @IBInspectable public var otherMonthColor: UIColor      @IBInspectable public var dayBackgrondColor: UIColor      @IBInspectable public var weekBackgrondColor: UIColor      @IBInspectable public var selectedBackgroundColor: UIColor      @IBInspectable public var selectedTextColor: UIColor</pre>    <p>You can configure the lots of color properties for appearance :weary:</p>    <p>Don't worry :stuck_out_tongue_closed_eyes: , you can easily configure appearance by using KoyomiStyle .</p>    <pre> = .tealBlue</pre>    <p style="text-align: center;"><img src=""></p>    <p>KoyomiStyle is defined by 10 types.</p>    <pre>  enum KoyomiStyle {          case monotone, standard, red, orange, yellow, tealBlue, blue, purple, green, pink      }</pre>    <h2><strong>:memo: Requirements</strong></h2>    <ul>     <li>iOS 8.0+</li>     <li>Xcode 8.0+</li>    </ul>    <h2><strong>:computer: Installation</strong></h2>    <p>Koyomi is available through CocoaPods . To install it, simply add the following line to your Podfile:</p>    <pre>  pod "Koyomi"</pre>    <h2><strong>:coffee:️ Author</strong></h2>    <p>shoheiyokoyama, <a href="/misc/goto?guid=4959721419944955350" rel="nofollow,noindex"></a></p>    <h2><strong>:unlock: License</strong></h2>    <p>Koyomi is available under the MIT license. See theLICENSE file for more info.</p>    <p> </p>    <p> </p>    <p> </p>