iphone的開發確實是非常複雜,先摸索出一條路來。
創建一個 view-base project, 然後創建一個類MainView,繼承UIView。
再綁定一下,在view controller裏 identity裏設定MainView。
加入quartzcore.framework, 否則用不了quartz畫圖。
MainView裏的drawRect就是要繪畫的函數。
CGContextRef ctx=UIGraphicsGetCurrentContext();
CGContextBeginPath(ctx);
CGContextAddArc(ctx, 110, 50, 30, 0, 2*M_PI, 1);
CGContextAddArc(ctx, 210, 50, 30, 0, 2*M_PI, 1);
CGContextAddArc(ctx, 160, 110, 15, 0, 2*M_PI, 1);
CGContextAddArc(ctx, 160, 210, 25, 0, 2*M_PI, 1);
CGContextFillPath(ctx);
這段是抄書上的,畫一個奇怪的圖,反正是畫了。
build and run就可以出來了。
當然整個結構還沒搞清楚,全無objective c的基礎,只是照貓畫虎。