1.json 用来解析json数据 https://github.com/stig/json-framework/downloads
2.Asihttprequest http封装 http://github.com/pokeb/asi-http-request/tarball/master
https://github.com/ahisbrook/AHTTPRequest/
3.
A delightful iOS and OS X networking framework
http://blog.csdn.net/duxinfeng2010/article/details/7830136
4.core Graphics学习
//
// graphicsView.m
// coreGraphicsExample
//
// Created by user on 13-8-9.
// Copyright (c) 2013年 wondershare. All rights reserved.
//
#import "graphicsView.h"
@implementation graphicsView
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
self.backgroundColor= [UIColor whiteColor];
}
return self;
}
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRectangle {
CGRect rectangle = CGRectMake(100, 290, 120, 25);
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGContextAddRect(ctx, rectangle);
CGContextSetFillColorWithColor(ctx, [UIColor redColor].CGColor);
CGContextFillPath(ctx);
}
// 绘制椭圆
- (void)drawEllipse {
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGRect rectangle = CGRectMake(10, 100, 300, 280);
CGContextAddEllipseInRect(ctx, rectangle);
CGContextSetFillColorWithColor(ctx, [UIColor orangeColor].CGColor);
CGContextFillPath(ctx);
}
- (void)drawTriangle {
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGContextBeginPath(ctx);
CGContextMoveToPoint(ctx, 160, 220);
CGContextAddLineToPoint(ctx, 190, 260);
CGContextAddLineToPoint(ctx, 130, 260);
CGContextClosePath(ctx);
CGContextSetFillColorWithColor(ctx, [UIColor blackColor].CGColor);
CGContextFillPath(ctx);
}
- (void)drawCurve {
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGContextBeginPath(ctx);
CGContextMoveToPoint(ctx, 160, 100);
CGContextAddQuadCurveToPoint(ctx, 160, 50, 190, 50);
CGContextSetLineWidth(ctx, 20);
CGContextSetStrokeColorWithColor(ctx, [UIColor brownColor].CGColor);
CGContextStrokePath(ctx);
}
- (void)drawCircleAtX:(float)x Y:(float)y {
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(ctx, [UIColor blackColor].CGColor);
CGContextAddArc(ctx, x, y, 20, 0, 2 * M_PI, 1);
CGContextFillPath(ctx);
}
- (void)drawText
{
// Drawing code
UIColor * magentaColor = [UIColor colorWithRed:0.5f green:0.0f blue:0.5f alpha:1.0f];
[magentaColor set];
UIFont * helveticaBold = [UIFont fontWithName:@"HelveticaNeue-Bold" size:30.0f];
NSString * myString = @"I Learn Really Fast";
[myString drawAtPoint:CGPointMake(25, 25) withFont:helveticaBold];
}
-(void)drawImage
{
UIImage * image = [UIImage imageNamed:@"image_7.jpg"];
if(image != nil)
{
NSLog(@"Successfully loaded the image");
}
else
{
NSLog(@"Failed to load the image");
}
[image drawAtPoint:CGPointMake(0.0f, 20.0f)];
[image drawInRect:CGRectMake(10.0f, 10.0f, 160.0f,240.0f)];
}
-(void)drawLine
{
//[[UIColor brownColor] set];
CGContextRef currentContext = UIGraphicsGetCurrentContext();
CGContextSetLineWidth(currentContext, 5.0f);
CGContextMoveToPoint(currentContext, 50.0f, 10.0f);
CGContextAddLineToPoint(currentContext, 100.0f, 200.0f);
CGContextStrokePath(currentContext);
}
-(void)drawTwoLine
{
[[UIColor brownColor] set];
CGContextRef currentContext = UIGraphicsGetCurrentContext();
CGContextSetLineWidth(currentContext, 5.0f);
CGContextMoveToPoint(currentContext, 20.0f, 20.0f);
CGContextAddLineToPoint(currentContext, 100.0f, 100.0f);
CGContextAddLineToPoint(currentContext, 300.0f, 100.0f);
CGContextStrokePath(currentContext);
}
-(void)drawRoot
{
[self drawRooftopAtTopPointof:CGPointMake(160.0f, 40.0f) textToDisplay:@"Miter" lineJoin:kCGLineJoinMiter];
[self drawRooftopAtTopPointof:CGPointMake(160.0f, 180.0f) textToDisplay:@"Bevel" lineJoin:kCGLineJoinBevel];
[self drawRooftopAtTopPointof:CGPointMake(160.0f, 320.0f) textToDisplay:@"Round" lineJoin:kCGLineJoinRound];
}
-(void)drawRooftopAtTopPointof:(CGPoint)paramTopPoint textToDisplay:(NSString * )paramText lineJoin:(CGLineJoin)paramLineJoin
{
[[UIColor brownColor] set];
CGContextRef currentContext = UIGraphicsGetCurrentContext();
CGContextSetLineJoin(currentContext,paramLineJoin);
CGContextSetLineWidth(currentContext, 20.0f);
CGContextMoveToPoint(currentContext, paramTopPoint.x - 140, paramTopPoint.y + 100);
CGContextAddLineToPoint(currentContext, paramTopPoint.x, paramTopPoint.y);
CGContextAddLineToPoint(currentContext, paramTopPoint.x + 140, paramTopPoint.y + 100);
CGContextStrokePath(currentContext);
[[UIColor blackColor] set];
[paramText drawAtPoint:CGPointMake(paramTopPoint.x - 40.0f, paramTopPoint.y + 60.0f) withFont:[UIFont boldSystemFontOfSize:30.0f]];
}
-(void)drawRectangle2
{
CGMutablePathRef path = CGPathCreateMutable();
CGRect rectangle = CGRectMake(10.0f, 10.0f, 100.0f, 150.0f);
CGPathAddRect(path, NULL, rectangle);
CGContextRef currentContext = UIGraphicsGetCurrentContext();
CGRect rectangle2 = CGRectMake(130.0f, 10.0f, 100.0f, 150.0f);
CGContextAddRect(currentContext, rectangle2);
CGContextSetFillColorWithColor(currentContext, [UIColor redColor].CGColor);
CGContextFillPath(currentContext);
CGContextAddPath(currentContext, path);
[[UIColor colorWithRed:0.20f green:0.60f blue:0.80f alpha:1.0f] setFill];
[[UIColor brownColor] setStroke];
CGContextSetLineWidth(currentContext, 5.0f);
CGContextDrawPath(currentContext, kCGPathFillStroke);
CGPathRelease(path);
}
-(void)drawMoreRectangle
{
CGMutablePathRef path = CGPathCreateMutable();
CGRect rectangle1 = CGRectMake(10.0f, 10.0f, 200.0f, 300.0f);
CGRect rectangle2 = CGRectMake(40.0f, 100.0f, 90.0f, 300.0f);
CGRect rectangles[2] = {rectangle1,rectangle2};
CGPathAddRects(path, NULL, (const CGRect *)&rectangles, 2);
CGContextRef currentContext = UIGraphicsGetCurrentContext();
CGContextAddPath(currentContext, path);
[[UIColor colorWithRed:0.20f green:0.60f blue:0.80f alpha:1.0f] setFill];
[[UIColor blackColor] setStroke];
CGContextDrawPath(currentContext, kCGPathFillStroke);
CGPathRelease(path);
}
-(void)drawRectAtTopOfScreen
{
CGContextRef currentContext = UIGraphicsGetCurrentContext();
CGContextSaveGState(currentContext);
CGContextSetShadowWithColor(currentContext, CGSizeMake(10.0f, 10.0f), 20.0f, [[UIColor grayColor] CGColor]);
CGMutablePathRef path = CGPathCreateMutable();
CGRect firstRect = CGRectMake(55.0f, 60.0f, 150.0f, 150.0f);
CGPathAddRect(path, NULL, firstRect);
CGContextAddPath(currentContext, path);
[[UIColor colorWithRed:0.20f green:0.60f blue:0.80f alpha:1.0f] setFill];
CGContextDrawPath(currentContext, kCGPathFill);
CGPathRelease(path);
CGContextRestoreGState(currentContext);
}
-(void)drawRectAtBottomOfScreen
{
CGContextRef currentContext = UIGraphicsGetCurrentContext();
CGMutablePathRef path = CGPathCreateMutable();
CGRect secondRect = CGRectMake(150.0f, 250.0f, 100.0f, 100.0f);
CGPathAddRect(path, NULL
, secondRect);
CGContextAddPath(currentContext, path);
[[UIColor purpleColor] setFill];
CGContextDrawPath(currentContext, kCGPathFill);
CGPathRelease(path);
}
- (void)drawRect:(CGRect)rect {
/*
// 绘制椭圆
[self drawEllipse];
// 绘制三角
[self drawTriangle];
// 绘制矩形
[self drawRectangle];
// 绘制曲线
[self drawCurve];
// 绘制圆形
[self drawCircleAtX:120 Y:170];
[self drawCircleAtX:200 Y:170];
*/
/*
[self drawText];
[self drawImage];
[self drawLine];
[self drawTwoLine];
*/
//[self drawRoot];
[self drawRectangle2];
//[self drawMoreRectangle];
//[self drawRectAtTopOfScreen];
//[self drawRectAtBottomOfScreen];
}
@end