zoukankan      html  css  js  c++  java
  • 【代码笔记】iOS-日历

    一, 效果图。

    二,工程图。

    三,代码。

    RootViewController.h

    复制代码
    #import <UIKit/UIKit.h>
    
    #import "CalendarView.h"
    #import "CalendarUtils.h"
    #import "CalendarStyle.h"
    
    @interface RootViewController : UIViewController
    <CalendarViewDelegate>
    {
        CalendarView *calendarView;
    }
    
    @end
    复制代码

     

    RootViewController.m

    复制代码
    #import "RootViewController.h"
    
    @interface RootViewController ()
    
    @end
    
    @implementation RootViewController
    
    - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
    {
        self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
        if (self) {
            // Custom initialization
        }
        return self;
    }
    
    - (void)viewDidLoad
    {
        [super viewDidLoad];
        // Do any additional setup after loading the view.
        
        self.title=@"Calendar";
        
        [self initWithCalendarView];
    
    }
    -(void)initWithCalendarView
    {
        if(calendarView)
            [calendarView removeFromSuperview];
        calendarView = [[CalendarView alloc]initWithFrame:CGRectMake(10, self.view.bounds.size.height - 200 - 320 + 20, 300, 300)];
        [calendarView refleshriCheng:^(NSDate *date,NSString *str) {
            if([str isEqualToString:@"left"]){
                
                UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"提醒" message:@"点击了左侧按钮" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
                [alert show];
            }
            else if([str isEqualToString:@"right"]){
                UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"提醒" message:@"点击了右侧按钮" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
                [alert show];
            }
        }];
        calendarView.delegate=self;
        [self.view addSubview:calendarView];
    }
    #pragma -mark -CalendarViewDelegate
    - (void) calendarViewDidSelectDate:(NSDate *)date todayDate:(NSDate *)todayDate
    {
        
        UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"提醒" message:@"点击了日期" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
        [alert show];
        
    }
    
    
    - (void)didReceiveMemoryWarning
    {
        [super didReceiveMemoryWarning];
        // Dispose of any resources that can be recreated.
    }
    复制代码

     

     

     
     
  • 相关阅读:
    Win10开启自带虚拟机
    C# NPOI Word 内容读写
    纯自绘实现的winform下卡片列表
    一个宽带问题
    windows两个命令
    Windows IP 安全策略
    vue自学入门-9 @click后直接跟alert报错
    企业微信创建自建应用-2(手机端)
    企业微信创建自建应用-1(管理端)
    Ngnix实践
  • 原文地址:https://www.cnblogs.com/yang-guang-girl/p/5215837.html
Copyright © 2011-2022 走看看