cgpoint

finding location of specific characters in UILabel on iPhone

北城以北 提交于 2019-12-17 19:46:52
问题 I have a UILabel with some text, say "Hello World abcdefg" The label can have multiple lines, different font sizes etc. Question : How do I find the coordinates of all letters "d" in this UILabel. Logical first step is find the position of those characters in the string (UILabel.text), but then how do I translate that into coordinates when it's actually drawn on screen The idea is to find those coordinates and draw something custom on top of that character (basically to cover it with a custom

Weird positioning issue when tabBar is present

隐身守侯 提交于 2019-12-12 21:07:15
问题 We have a custom view with a UIPickerView plus toolbar (216 + 44). At init time (viewDidLoad) this custom view is pushed below the screen using the following piece of code. CGPoint newOrigin; newOrigin.x = pickerViewOutlet.frame.size.width/2; newOrigin.y = self.view.frame.size.height + ((pickerViewOutlet.frame.size.height)/2); NSLog(@"%f,%f",self.view.frame.size.height,(pickerViewOutlet.frame.size.height)/2); pickerViewOutlet.center = CGPointMake(newOrigin.x, newOrigin.y); When a button is

Objective C: UIScrollView (pagingEnabled): When Next Page Enters Start The Animation

橙三吉。 提交于 2019-12-12 04:49:49
问题 I'm sorry for the title i don't know what to write there. I have a scrollView with many pages and in each page there are different animations that should start when the user switch to that page. i tried this: if (CGPointEqualToPoint (CGPointZero, CGPointZero)) { //start animation } it worked only for the first page when i changed it to CGPointEqualToPoint (CGPointMake (768, 0), CGPointZero) for the next page, it's not working. i am trying to use this ` - (void)scrollViewWillEndDragging:

color of cgpoint changes all lines and should only change new lines

ⅰ亾dé卋堺 提交于 2019-12-11 14:29:45
问题 My code uses to classes. When the function dizzy is called it changes the color of all the lines in the uiview. What I want it to do is only change lines colors that are drawn after the function is called. It should not change the color of the lines that are already drawn like it does now. class ViewController: UIViewController { @objc func dizzy() { canvas.strokeColor = .gray } var canvas = Canvas() } class Canvas: UIView { var strokeColor = UIColor.green { didSet { self.setNeedsDisplay() }

How to find out uncoloured area uibeizerpath?

人走茶凉 提交于 2019-12-11 12:46:26
问题 That greycolour is UIImageView and the White colour font is Image. That image Placed inside UIImageView. I like to colour only inside the font ,not an whole UIImageview for that i am going to find out the coordinates of the image . i am new to this kind of concept so kindly some one guide me how to colour only inside the image ,there are 50+ images is there ,it is not static so give some good idea . This is the code i am using to draw inside the UIImageView: -(void)touchesMoved:(NSSet<UITouch

How to Create a Dynamic CGPoint** array

微笑、不失礼 提交于 2019-12-11 06:00:02
问题 I have a few maps (tilemaps made with Tiled QT) and I would like to create a CGpoint **array based on the objects groups of those maps (I call them Waypoints). Each maps can have a few set of waypoints that I call path. //Create the first dimension int nbrOfPaths = [[self.tileMap objectGroups] count]; CGPoint **pathArray = malloc(nbrOfPaths * sizeof(CGPoint *)); Then for the second dimension //Create the second dimension int pathCounter = 0; while ((path = [self.tileMap objectGroupNamed:

Getting a CGPoint on a UIBezierpath

送分小仙女□ 提交于 2019-12-11 04:14:49
问题 In my app I have a MKOverlayPathView where I draw a QuadCurve between two points which works just fine. Here is the code I use: MKMapPoint mkDepPoint = MKMapPointForCoordinate([(RoutePath *)self.overlay startCoordinate]); MKMapPoint mkArrPoint = MKMapPointForCoordinate([(RoutePath *)self.overlay endCoordinate]); CGPoint dePoint = [self pointForMapPoint:mkDepPoint]; CGPoint arrPoint = [self pointForMapPoint:mkArrPoint]; CGPoint s = depPoint; CGPoint e = arrPoint; ... some awesome code ...

Create random CGPoint with Swift

社会主义新天地 提交于 2019-12-11 02:37:29
问题 So, I'm trying to develop a simple game written in Swift, but I'm having trouble doing a pretty simple thing. I can't manage to create a random CGPoint... When using arc4random, a compiler error shows up telling me that I can't use Int32 in a CGPoint. So, Is there any way to do this? Any workaround? Thanks! 回答1: hi what about constructing an Int? Int(arc4random()) e.g. var p = CGPoint(x:Int(arc4random()%1000),y:Int(arc4random()%1000)) 回答2: can also maybe make use of Swift's extensions of base

How to convert between vector_float2 and CGPoint*?

情到浓时终转凉″ 提交于 2019-12-10 18:25:50
问题 What's the easiest/fastest way to convert between vector_float2 and CGPoint* in Objective-C? Does Apple provide any built-in functionality for this kind of type conversion? I noticed in 2-3 places in sample apps they just call CGPointMake() etc. to make the conversion Is it possible to simply cast a CGPoint* to vector_float2 and vice versa? Is it safe to do so? Update: obviously the solution is: vector_float2 v = (vector_float2){(float)point.x, (float)point.y}; CGPoint p = CGPointMake(v.x, v

NSDictionary to CGPoint

坚强是说给别人听的谎言 提交于 2019-12-10 12:27:42
问题 I am working on a game, in which i am trying to fire two different types if bullets on single tap and double tap respectively. Heres what I am doing in my touch began method: - (void)ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { for( UITouch *touch in touches ) { CGPoint location = [touch locationInView: [touch view]]; location = [[CCDirector sharedDirector] convertToGL: location]; NSLog(@"TOUCH LOCATION IN TOUCH BEGAN = (%f , %f)", location.x , location.y); NSUInteger tapCount