Tag: 线

获取UITextView上特定行的文本

最终,我想知道UITextView中最后一个字符的位置。 我能够通过使用以下方法找出y位置: CGSize size = [textView.text sizeWithFont:textView.font constrainedToSize:CGSizeMake(textView.frame.size.width-16,10000)lineBreakMode:UILineBreakModeClip]; 但是为了得到x的位置,我需要从textview的最后一行获取文本。 我试图从textView.text中删除一个字符,直到size.height改变,以实现这一效果,但我意识到,并不总是等于我想要的,当linebreak被考虑到。 任何build议任何人? 我已经花了整整一天的时间来试图找出这一个…

摆脱UITableView上面的行

我有一个UITableView (正好有一个UISearchBar ),似乎无法弄清楚如何摆脱它上面的白色/灰色边框。 我需要在UISearchBar和上面的黑色之间有无缝的黑色。 我试图隐藏UISearchBar ,看看是否与它有任何关系,但该行仍然出现。 有任何想法吗?

删除UITabbar上边界线

我一直在应用程序中使用UITabbar。 UITabbar顶部有一个上边界线。 请参阅下图: 我谷歌search,并尝试build议的代码,如: [[UITabBar appearance] setShadowImage:[[UIImage alloc] init]]; 也 [[UITabBar appearance] setShadowImage:nil]; self.navigationController.toolbar.clipsToBounds = YES; 但他们都没有工作。 任何解决scheme

绘制一条直线iOS

我正在用这个代码绘制一条直线(很明显用户触摸),我需要从起点显示直线,直到用户从起始点像橡皮筋一样保持触摸(而不是结束触摸)随手指移动。 我可能忽略了一些我需要修改的东西来创build必要的效果。 任何想法? 注:我在一个视图控制器。 – (void) drawLine:(UIPanGestureRecognizer *)sender { NSLog(@"Sender : %@", sender); CGPoint currentPoint; //CGAffineTransformMakeScale(lastScale, lastScale); if([(UIPanGestureRecognizer *)sender state] == UIGestureRecognizerStateBegan || [(UIPanGestureRecognizer *)sender state] == UIGestureRecognizerStateChanged) { currentPoint = [(UIPanGestureRecognizer *)sender locationInView:imgView]; previousPoint = currentPoint; } if([(UIPanGestureRecognizer *)sender state] == UIGestureRecognizerStateChanged) { touchedPoint = [(UIPanGestureRecognizer *)sender locationInView:imgView]; [imgView setNeedsDisplay]; } if([(UIPanGestureRecognizer *)sender state] […]

在iPhone中使用OpenGL ES绘制直线?

最后,我试图在XCode 4.2中使用OpenGL ES框架为iPhone简单的游戏app.I研究了一些关于GLKView和GLKViewController在iPhone中绘制一条线。 这是我在我的项目中尝试过的示例代码, @synthesize context = _context; @synthesize effect = _effect; – (void)viewDidLoad { [super viewDidLoad]; self.context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2]; if (!self.context) { NSLog(@"Failed to create ES context"); } GLKView *view = (GLKView *)self.view; view.context = self.context; view.drawableDepthFormat = GLKViewDrawableDepthFormat24; [EAGLContext setCurrentContext:self.context]; //[self setupGL]; } – (void)glkView:(GLKView *)view drawInRect:(CGRect)rect { NSLog(@"DrawInRect Method"); [EAGLContext […]

用SpriteKitanimation可以画出一条线吗?

我想从苹果SpriteKit框架中让我们说A(100,50)到B(250,450)。 到目前为止,我能够使用SKShapeNode绘制这条线,并设置其path属性。 我想要实现的是画这条线。 可以说,从A点到B点画线需要2秒钟的时间。 我看着SKAction类,但似乎没有任何方法默认支持此function。 这是我用来创build该行的代码: CGMutablePathRef path = CGPathCreateMutable(); CGPathMoveToPoint(path, NULL, 100, 50); CGPathAddLineToPoint(path, NULL, 250.0, 450.0); SKShapeNode *line = [SKShapeNode node]; line.path = path; [line setStrokeColor:[UIColor whiteColor]]; [self addChild:line]; 任何人都可以指向正确的方向吗?

检查用户是否遵循路线(iphone)

我正在做一个基于导航的应用程序。 在这个应用程序中,我正在绘制从用户select的点的路线。 如果用户没有遵循路线,我有重新计算路线的要求。 计算我使用Google direction API的路线。 并绘制我使用此代码的路线 – (void) drawRoute:(NSArray *) path { NSInteger numberOfSteps = path.count; [self.objMapView removeOverlays: self.objMapView.overlays]; CLLocationCoordinate2D coordinates[numberOfSteps]; for (NSInteger index = 0; index < numberOfSteps; index++) { CLLocation *location = [path objectAtIndex:index]; CLLocationCoordinate2D coordinate = location.coordinate; coordinates[index] = coordinate; } for( id <MKOverlay> ovr in [self.objMapView overlays]) { MKPolylineView *polylineView […]

如何在UIView中绘制与MKPolyline相同的UIBezierPath

目前我正在跟踪我的位置在一个MKMapView。 我的目标是绘制一个与从追踪位置创build的MKPolyline相同的贝塞尔path。 我所尝试的是:将所有位置坐标存储在CLLocation数组中。 迭代该数组,并将经纬度坐标存储在CLLocationCoordinate2D数组中。 然后确保多段线在屏幕的视图中,然后转换CGPoints中的所有位置坐标。 当前尝试: @IBOutlet weak var bezierPathView: UIView! var locations = [CLLocation]() // values from didUpdateLocation(_:) func createBezierPath() { bezierPathView.isHidden = false var coordinates = [CLLocationCoordinate2D]() for location in locations { coordinates.append(location.coordinate) } let polyline = MKPolyline(coordinates: coordinates, count: coordinates.count) fitPolylineInView(polyline: polyline) let mapPoints = polyline.points() var points = [CGPoint]() for point […]

iOS MapKit通过道路在地图上连接多个点

我正在使用此代码连接折线上的针脚(地图上的点): CLLocationCoordinate2D coordinates[allLocations.count]; int i = 0; for (locHolder *location in allLocations) { coordinates[i] = CLLocationCoordinate2DMake([location.lat floatValue], [location floatValue]); i++; } MKPolyline *polyline = [MKPolyline polylineWithCoordinates:coordinates count:[allLocations count]]; self->polyline = polyline; [self.mapView addOverlay:self->polyline level:MKOverlayLevelAboveRoads]; 但是这个代码将它们连接在空中(忽略道路),是否有可能将多个CLLocationCoordinate2D位置连接到沿着道路的多段线? **还有一个小问题,[allLocations count]和allLocations.count之间的性能是否有差异? 谢谢。