CGRect に境界線を追加したい。以前のソリューションは次のいずれかを示唆していますが:
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetRGBFillColor(context, 1.0, 0.0, 0.0, 1.0);
CGContextSetRGBStrokeColor(context, 1.0, 0.0, 0.0, 1.0);
CGContextFillRect(context, rectangle);
またはこのようなもの:
view.layer.borderWidth = 10;
view.layer.borderColor = [UIColor redColor].CGColor;
私のアプローチでは、これのどちらも適用できません。
私の mainView Controller には、次のコードがあります。
-(void)actionHint
{
CGRect viewRect = CGRectMake(kScreenWidth/2 -kMenuWidth, kScreenHeight/2-kMenuHeight - 70,kMenuWidth*10, kMenuHeight*4);
HintMenu* hintMenu = [HintMenu viewWithRect:viewRect];
[hintMenu.btnReveal addTarget:self action:@selector(actionReveal) forControlEvents:UIControlEventTouchUpInside];
[hintMenu.btnNewAnag addTarget:self action:@selector(actionNewAnagram) forControlEvents:UIControlEventTouchUpInside];
[self.gameView addSubview:hintMenu];
}
ゲームを作成していますが、いくつかのヘルプ アクションを含む単純な四角形を現在のビューの上に表示したいと考えています。viewRect のコードは次のとおりです。
+(instancetype)viewWithRect:(CGRect)r
{
HintMenu* hint = [[HintMenu alloc] initWithFrame:r];
hint.userInteractionEnabled = YES;
UIImage* image=[UIImage imageNamed:@"btn"];
... rest of items in the cgrect
return hint;
}
境界線を追加するためのコードはどこに追加すればよいですか? また、そのコードは何を追加すればよいですか?