我想在我的應用程序中實現和設計建築物地板的地圖。在開始之前,我想提供一些建議。如何繪製UIBezierPath並與之交互
我打算使用UIBezierPath繪製形狀。每個UIBezierPath將在我的地圖上代表一家商店。 這裏是一個例子(map_with_UIBezierPath)
我的代碼結構如下:我有一個UIViewController和一個UiView。在UIViewController的「viewDidLoad中」的方法,我實例化的UIView和UIView的「的drawRect」的方法,我得出的形狀像以下(UIBezierPathExtension從UIBezierPath繼承):
- (void)drawRect:(CGRect)rect {
context = UIGraphicsGetCurrentContext();
[[UIColor grayColor] setFill];
[[UIColor greenColor] setStroke];
UIBezierPathExtension *aPath = [[UIBezierPathExtension alloc] init];
aPath.pathId = 1;
[aPath moveToPoint:CGPointMake(227,34.25)];
[aPath addLineToPoint:CGPointMake(298.25,34.75)];
[aPath addLineToPoint:CGPointMake(298.5,82.5)];
[aPath addLineToPoint:CGPointMake(251,83)];
[aPath addLineToPoint:CGPointMake(251,67.5)];
[aPath addLineToPoint:CGPointMake(227.25,66.75)];
[aPath closePath];
aPath.lineWidth = 2;
[aPath fill];
[aPath stroke];
[paths addObject:aPath];
UIBezierPathExtension* aPath2 = [[UIBezierPathExtension alloc] init];
aPath2.pathId = 2;
[aPath2 moveToPoint:CGPointMake(251.25,90.5)];
[aPath2 addLineToPoint:CGPointMake(250.75,83.25)];
[aPath2 addLineToPoint:CGPointMake(298.5,83)];
[aPath2 addLineToPoint:CGPointMake(298.5,90.25)];
[aPath2 closePath];
aPath2.lineWidth = 2;
[aPath2 fill];
[aPath2 stroke];
[paths addObject:aPath2];
...
}
我也實施平移和縮放手勢在UIViewController中。
現在,我問我如何與每一個形狀交互。我想檢測一下它,改變他的顏色並在選定的形狀上顯示一個像that這樣的菜單。
有人可以告訴我正確的方向嗎?
THX提前