Permalink
Browse files

Pushing code

  • Loading branch information...
1 parent 9ada786 commit dd6ca9434afe237e6d8cd1c892f3aabcbe9771e2 @afrael afrael committed Jul 15, 2011
View
@@ -0,0 +1,21 @@
+//
+// OANotebookView.h
+// Notebook
+//
+// Created by afrael on 7/13/11.
+// Copyright 2011 Obelisk Apps. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+#import <QuartzCore/QuartzCore.h>
+
+@interface OANotebookView : UIView{
+
+}
+
+- (UIImage *) patternImageOfSize:(CGSize) size;
+- (void) setBackgroundTexture;
+- (void) drawHorizonalBlueLines: (CGContextRef) ctx;
+- (void) drawVerticalMarginLine: (CGContextRef) ctx;
+
+@end
View
@@ -0,0 +1,91 @@
+//
+// OANotebookView.m
+// Notebook
+//
+// Created by afrael on 7/13/11.
+// Copyright 2011 Obelisk Apps. All rights reserved.
+//
+
+#import "OANotebookView.h"
+
+@implementation OANotebookView
+
+- (id)initWithFrame:(CGRect)frame
+{
+ self = [super initWithFrame:frame];
+ if (self) {
+ // Initialization code
+ }
+ return self;
+}
+
+
+- (void)drawRect:(CGRect)rect
+{
+ CGContextRef ctx = UIGraphicsGetCurrentContext();
+ CGContextSetFillColorWithColor(ctx, [UIColor blackColor].CGColor);
+ CGContextFillRect(ctx, self.bounds);
+ UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:self.bounds
+ byRoundingCorners:UIRectCornerAllCorners
+ cornerRadii:CGSizeMake(8.0f, 8.0f)];
+ [path addClip];
+ [self setBackgroundTexture];
+ [self drawHorizonalBlueLines: ctx];
+ [self drawVerticalMarginLine: ctx];
+ [super drawRect:rect];
+}
+
+- (UIImage *) patternImageOfSize:(CGSize) size{
+ UIImage *image = [UIImage imageNamed:@"paper"];
+ return image;
+}
+
+- (void) setBackgroundTexture{
+ UIImage *paperPatternImage = [self patternImageOfSize:CGSizeMake(32.0, 32.0)];
+ [[UIColor colorWithPatternImage:paperPatternImage] setFill];
+ UIBezierPath *path = [UIBezierPath bezierPathWithRect:self.bounds];
+ [path fill];
+}
+
+- (void) drawHorizonalBlueLines: (CGContextRef) ctx{
+ CGContextSaveGState(ctx);
+ CGRect screenRect = [[UIScreen mainScreen] bounds];
+ CGFloat screenWidth = screenRect.size.width;
+ screenWidth -= 10;
+ UIColor *lineColor = [UIColor colorWithRed:0/255.0
+ green:124.0/255.0
+ blue:255.0/255.0
+ alpha:0.5];
+ UIBezierPath *path = [UIBezierPath bezierPath];
+ [path moveToPoint:CGPointMake(10, 40.5)];
+ [path addLineToPoint:CGPointMake(screenWidth, 40.5)];
+ [path setLineWidth:1.0];
+ [lineColor setStroke];
+ [path stroke];
+ for (int i = 0; i < 9; i++) {
+ CGContextTranslateCTM(ctx, 0.0, (40 + i));
+ [path stroke];
+ }
+ CGContextRestoreGState(ctx);
+}
+
+- (void) drawVerticalMarginLine: (CGContextRef) ctx{
+ CGRect screenRect = [[UIScreen mainScreen] bounds];
+ CGFloat screenHeight = screenRect.size.height;
+ screenHeight -= 2;
+ UIColor *lineColor = [UIColor colorWithRed:255.0/255.0
+ green:142.0/255.0
+ blue:142.0/255.0
+ alpha:0.5];
+ UIBezierPath *path = [UIBezierPath bezierPath];
+ [path moveToPoint:CGPointMake(40.5, 2.0)];
+ [path addLineToPoint:CGPointMake(40.5, (screenHeight -2))];
+ [path setLineWidth:1.0];
+ [lineColor setStroke];
+ [path stroke];
+ [path moveToPoint:CGPointMake(42.5, 2.0)];
+ [path addLineToPoint:CGPointMake(42.5, (screenHeight -2))];
+ [path stroke];
+}
+
+@end
Oops, something went wrong.

0 comments on commit dd6ca94

Please sign in to comment.