国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > iOS > 正文

iOS實現一個簡易日歷代碼

2019-10-21 18:47:20
字體:
來源:轉載
供稿:網友

日歷一般都是用UICollectionView進行開發的,相關demo也很多,這里就講一個我最近寫的玩的demo,由于時間原因沒來得及加年歷和周歷,一個月歷的小demo,隨著月份天數的不同,自動改變日歷的高。

代理部分:

@protocol KJCalendarDelegate <NSObject>/** 隨著每個月的天數不一樣而改變高度 @param height 日歷高度 */- (void)calendarViewHeightChange:(CGFloat)height;/** 當前展示的年和月,當類型是年歷的時候,只返回年 @param year 年 @param month 月 */- (void)currentShowYear:(NSInteger)year withMonth:(NSInteger)month;/** 選中的時間 @param solar 陽歷 @param lunar 農歷 */- (void)selectSolarDate:(NSString *)solar withLunar:(NSString *)lunar;@end

這個當時創建文件的時候,沒注意,KJCalendar寫成了KJCanlendar,抱歉。。。

下面是可自定義的部分:

//======以下屬性可自定義======//背景顏色@property (strong, nonatomic) UIColor *bgColor;//weekView背景色 默認clearcolor@property (strong, nonatomic) UIColor *weekColor;//選擇狀態下的背景顏色@property (strong, nonatomic) UIColor *selectBgColor;//選擇狀態下的字體顏色@property (strong, nonatomic) UIColor *selectTitleColor;//普通狀態下公歷字體顏色@property (strong, nonatomic) UIColor *normalDateTitleColor;//普通狀態下農歷字體顏色@property (strong, nonatomic) UIColor *normalLunerTitleColor;//今天的字體顏色@property (strong, nonatomic) UIColor *todayTitleColor;//今天選擇狀態下的背景顏色@property (strong, nonatomic) UIColor *todaySelectBgColor;//今天選擇狀態下的字體顏色@property (strong, nonatomic) UIColor *todaySelectTitleColor;//距屏幕左右間隔,默認8@property (assign, nonatomic) CGFloat screenInSpace;//每行(item)的高度,設置的高度不能大于寬度,寬度的來源是屏幕的寬減去左右間隔除以7得到@property (assign, nonatomic) CGFloat rowHeight;//設置是否顯示陰歷 YES-顯示 NO-隱藏 默認YES@property (assign, nonatomic) BOOL isShowLunar;//公歷字體 默認system 13@property (strong, nonatomic) UIFont *dateFont;//農歷字體 默認system 8@property (strong, nonatomic) UIFont *lunerFont;//選中時公歷字體 默認 [UIFont boldSystemFontOfSize:13.0f];@property (strong, nonatomic) UIFont *dateSelectFont;//選中時農歷字體 默認 [UIFont boldSystemFontOfSize:8.0f];@property (strong, nonatomic) UIFont *lunerSelectFont;

使用也很簡單:

//高度是根據日歷的月份天數決定的  self.calView = [[KJCanlendarView alloc] initWithY:0 withNavc:YES andLeastYear:0];  self.calView.kjDelegate = self;  [self.calView showKJCalendarInCtrl:self];

每個屬性都有默認值,需要改變賦值即可,當然啦,設置字體時,要調整背景圓圈的大小以及rouHeight的大小,具體的下面我給出demo,就不多說了,大家就隨便看看,寫的很隨意,希望能幫到大家。

demo:KJCalendar.rar

效果圖:

ios,日歷代碼,iOS實現,日歷

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持VEVB武林網。


注:相關教程知識閱讀請移步到IOS開發頻道。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 延津县| 兰考县| 宣化县| 福安市| 扎赉特旗| 阿合奇县| 军事| 星子县| 古浪县| 滦平县| 呼伦贝尔市| 兴仁县| 阿瓦提县| 昌邑市| 琼海市| 江北区| 丹阳市| 周至县| 马山县| 阿城市| 保康县| 永年县| 资源县| 安平县| 大洼县| 三亚市| 万宁市| 嵩明县| 谢通门县| 宜州市| 佛坪县| 城固县| 息烽县| 新竹县| 靖江市| 莒南县| 嘉鱼县| 香河县| 云阳县| 平谷区| 青阳县|