I want to draw straight line between two UIButtons. When we touch button 1 the line will appear in black color; when we touch button 3 the line will become red; and when we touch button 2 the line will become Green and end on Button two. So that line will be visible connected two buttons only button 1 and button 2.
Now I want when I click button 4 the new line will appear in orange color. The previous line was end on button-2 and this will be the new line. And same this will connect if I touch button 5.
Same just like kids play matching the quiz game.
Means Tv belongs to electronics (Right), sky belong to Glass (wrong). Just like that I need to connect Button 1 and Button 2 , Button 4 and Button 5.
Any idea or suggestions would be highly welcome.
一种简单的方法是在按钮周围放置一些uiimageviews,并根据每个按钮的作用,根据需要在uiimageviews中添加图像或从uiimageviews中移除图像(使用不同的彩色线条)。
You can do it with the help of images. Just write your logic for replacing, hiding and unhiding the images. It would be a simpler approach.
Use this:
-(void)drawLineWithStartPoint:(CGPoint)startPoint endPoint:(CGPoint)endPoint WithColor:(UIColor *)color
{
UIBezierPath *aPath = [UIBezierPath bezierPath];
// Set the starting point of the shape.
[aPath moveToPoint:startpoint;
// Draw the lines.
[aPath addLineToPoint:endPoint;
[aPath closePath];
aPath.lineWidth = 2;
[aPath fill];
[aPath stroke];
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.