Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
546 changes: 546 additions & 0 deletions 21651049陈昊川/project02/iosCal.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions 21651049陈昊川/project02/iosCal/AppDelegate.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// AppDelegate.h
// iosCal
//
// Created by Nick Alan on 10/25/16.
// Copyright © 2016 Nick Alan. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface AppDelegate : UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) UIWindow *window;


@end

51 changes: 51 additions & 0 deletions 21651049陈昊川/project02/iosCal/AppDelegate.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
//
// AppDelegate.m
// iosCal
//
// Created by Nick Alan on 10/25/16.
// Copyright © 2016 Nick Alan. All rights reserved.
//

#import "AppDelegate.h"

@interface AppDelegate ()

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
return YES;
}


- (void)applicationWillResignActive:(UIApplication *)application {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
}


- (void)applicationDidEnterBackground:(UIApplication *)application {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}


- (void)applicationWillEnterForeground:(UIApplication *)application {
// Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
}


- (void)applicationDidBecomeActive:(UIApplication *)application {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}


- (void)applicationWillTerminate:(UIApplication *)application {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}


@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"images" : [
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11134" systemVersion="15F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11106"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="EHf-IW-A2E">
<objects>
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="Llm-lL-Icb"/>
<viewControllerLayoutGuide type="bottom" id="xb3-aO-Qok"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="53" y="375"/>
</scene>
</scenes>
</document>
43 changes: 43 additions & 0 deletions 21651049陈昊川/project02/iosCal/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11201" systemVersion="15G1004" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11161"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="tne-QT-ifu">
<objects>
<viewController id="BYZ-38-t0r" customClass="ViewController" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="y3c-jy-aDJ"/>
<viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="center" horizontalHuggingPriority="251" verticalHuggingPriority="251" misplaced="YES" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="S85-zj-QY9">
<frame key="frameInset" minX="83" minY="233" width="209" height="200"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="S85-zj-QY9" firstAttribute="centerY" secondItem="8bC-Xf-vdC" secondAttribute="centerY" id="uac-cx-xOC"/>
<constraint firstItem="S85-zj-QY9" firstAttribute="centerX" secondItem="8bC-Xf-vdC" secondAttribute="centerX" id="zxS-Pt-3eD"/>
</constraints>
</view>
<connections>
<outlet property="lab" destination="S85-zj-QY9" id="yOK-so-vxC"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="24.800000000000001" y="36.431784107946029"/>
</scene>
</scenes>
</document>
38 changes: 38 additions & 0 deletions 21651049陈昊川/project02/iosCal/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>
28 changes: 28 additions & 0 deletions 21651049陈昊川/project02/iosCal/MYMonthView.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//
// MYMonthView.h
// MyCal
//
// Created by Nick Alan on 10/23/16.
// Copyright © 2016 Nick Alan. All rights reserved.
//

#import <Foundation/Foundation.h>

enum{
MYMonthViewWidth = 20,
MYMonthViewHeight = 8
};

@class MyViewBuffer;

@interface MYMonthView : NSObject

@property NSInteger year;
@property NSInteger month;
@property Boolean standAlone;
@property (strong) MyViewBuffer *viewBuffer;

+(NSArray*)monthNames;
-(instancetype)initWithMonth:(NSInteger)month andYear:(NSInteger)year andStandAlone:(Boolean)standAlone;

@end
112 changes: 112 additions & 0 deletions 21651049陈昊川/project02/iosCal/MYMonthView.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
//
// MYMonthView.m
// MyCal
//
// Created by Nick Alan on 10/23/16.
// Copyright © 2016 Nick Alan. All rights reserved.
//

#import "MYMonthView.h"
#import "MyViewBuffer.h"

@interface MYMonthView()

+(NSArray*)weekdayNames;
-(void)writeTitleOfMonth;
-(void)writeTitleOfWeekdays;
-(void)writeDays;

@end

@implementation MYMonthView

+(NSArray*)monthNames;
{
static NSArray* _monthNames;
if(_monthNames == nil)
{
_monthNames = @[@"January",
@"February",
@"March",
@"April",
@"May",
@"June",
@"July",
@"August",
@"September",
@"October",
@"November",
@"December"];
}
return _monthNames;
}

+(NSArray*)weekdayNames
{
static NSArray* _weekdayNames;
if(_weekdayNames == nil){
_weekdayNames = @[@"Su",@"Mo",@"Tu",@"We",@"Th",@"Fr",@"Sa"];
}
return _weekdayNames;
}

-(instancetype)initWithMonth:(NSInteger)month andYear:(NSInteger)year andStandAlone:(Boolean)standAlone
{
self = [super init];
if(self)
{
_month = month;
_year = year;
_standAlone = standAlone;
_viewBuffer = [[MyViewBuffer alloc] initWithWidth:MYMonthViewWidth andHeight:MYMonthViewHeight];

[self writeTitleOfMonth];
[self writeTitleOfWeekdays];
[self writeDays];
}
return self;
}

-(void)writeTitleOfMonth
{
NSString *monthName = [[self class] monthNames] [_month-1];
NSString *title = monthName;
if(_standAlone)
{
title = [NSString stringWithFormat:@"%@ %ld",monthName,(long)_year];
}
NSInteger x = (_viewBuffer.width-title.length) / 2;
[_viewBuffer writeString:title toX:x andY:0];
}

-(void)writeTitleOfWeekdays
{
NSString *title = [[[self class] weekdayNames] componentsJoinedByString:@" "];
[_viewBuffer writeString:title toX:0 andY:1];
}

-(void)writeDays
{
NSCalendar *calender = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian];
NSDateComponents *dateComponents = [[NSDateComponents alloc] init];
dateComponents.year = _year;
dateComponents.month = _month;
NSDate *date = [calender dateFromComponents:dateComponents];
NSRange days = [calender rangeOfUnit:NSCalendarUnitDay inUnit:NSCalendarUnitMonth forDate:date];

for(NSInteger day = 1;day <= days.length;day++)
{
dateComponents.day = day;
date = [calender dateFromComponents:dateComponents];

NSInteger weekOfMonth = [calender component:NSCalendarUnitWeekOfMonth fromDate:date];
NSInteger weekday = [calender component:NSCalendarUnitWeekday fromDate:date];

NSString *dayString = [NSString stringWithFormat:@"%2ld",(long)day];
NSInteger x = (weekday-1) * 3;
NSInteger y = weekOfMonth + 1;
[_viewBuffer writeString:dayString toX:x andY:y];
}
}

@end
20 changes: 20 additions & 0 deletions 21651049陈昊川/project02/iosCal/MYYearView.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//
// MYYearView.h
// MyCal
//
// Created by Nick Alan on 10/24/16.
// Copyright © 2016 Nick Alan. All rights reserved.
//

#import <Foundation/Foundation.h>

@class MyViewBuffer;

@interface MYYearView : NSObject

@property NSInteger year;
@property(strong) MyViewBuffer *viewBuffer;

-(instancetype)initWithYear:(NSInteger)year;

@end
Loading