• 【代码笔记】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.
    }
    复制代码

     

     

     
     
  • 相关阅读:
    crystal report 用存储过程的问题。
    新的开始—2014
    C#基础(二)——C#中的构造函数
    C#基础(一)——C#中反斜杠/n与/r的区别
    Html基础(一)
    yield关键字, default关键字, 别名关键字
    让 wpf tabcontrol 延缓初始化每个tab item content
    MVC,MVP,MVVM(补充)
    Focus scope in WPF
    Wpf ItemsControl 开启UI Virtualization 的条件
  • 原文地址:https://www.cnblogs.com/yang-guang-girl/p/5215837.html
Copyright © 2020-2023  润新知