さて目標はボタンを作ることなので on/offの状態を描かなければならない。前回までで描いた Bezel の反対、すなわち今度は浮き出た(飛び出た?)表現を作る。
といっても既に影を描くところで作ったのでコードを整理するだけ。
- (void)drawRect:(CGRect)rect {
CGRect frame = CGRectInset([self bounds], INSET_SIZE, INSET_SIZE);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSaveGState(context);
[self addRoundRectPath:context rect:frame];
CGContextSetShadow(context, CGSizeMake(SHADOW_SIZE, -SHADOW_SIZE), SHADOW_BLUR);
[[UIColor whiteColor] setFill];
CGContextFillPath(context);
CGContextRestoreGState(context);
[self addRoundRectPath:context rect:frame];
[[UIColor colorWithRed:0.75f green:0.75f blue:0.75f alpha:1.0f] setStroke];
CGContextSetLineWidth(context, 0.5f);
CGContextStrokePath(context);
}こちらも縁取りしてある。さて次は Touchイベントを広って表示を切り替える(トグル動作)。




Responses
Leave a Response