drawrect

getting the text up-side down in core graphic

99封情书 提交于 2020-01-16 19:57:27
问题 I am drawing a text in core graphic by following - (void)drawRect:(CGRect)rect { CGContextTranslateCTM(context, 20, 150); CGContextScaleCTM(context, 1, 1); // Draw the text using the MyDrawText function myDrawText(context, viewBounds); } void myDrawText (CGContextRef myContext, CGRect contextRect) { CGFloat w, h; w = contextRect.size.width; h = contextRect.size.height; CGAffineTransform myTextTransform; CGContextSelectFont (myContext, "Helvetica-Bold", h/12, kCGEncodingMacRoman);

Rotating a NSString in drawRect

半腔热情 提交于 2020-01-07 01:59:56
问题 I want to rotate my NSString that's at a set location so that it reads from bottom to up. I know the issue lies in the CGContextTranslateCTM, but I'm not sure how to fix it. If I comment this line, I see my text where I want it, just not rotated. This must be moving my NSString to where it is not visible. Thoughts? Here's what I have tried: NSString * xString = [NSString stringWithFormat:@"%@", self.xStringValue]; CGContextSetFillColorWithColor(UIGraphicsGetCurrentContext(), [[UIColor

Rotating a NSString in drawRect

可紊 提交于 2020-01-07 01:59:27
问题 I want to rotate my NSString that's at a set location so that it reads from bottom to up. I know the issue lies in the CGContextTranslateCTM, but I'm not sure how to fix it. If I comment this line, I see my text where I want it, just not rotated. This must be moving my NSString to where it is not visible. Thoughts? Here's what I have tried: NSString * xString = [NSString stringWithFormat:@"%@", self.xStringValue]; CGContextSetFillColorWithColor(UIGraphicsGetCurrentContext(), [[UIColor

Put shadow to a rectangle (drawRect:(CGRect)rect)

醉酒当歌 提交于 2020-01-06 08:23:45
问题 I did a rectangle with this code and it works: - (void)drawRect:(CGRect)rect{ CGContextRef context = UIGraphicsGetCurrentContext(); CGContextAddRect(context, CGRectMake(60, 60, 100, 1)); CGContextStrokePath(context); } But now i want to put a shadow, I tried with this: NSShadow* theShadow = [[NSShadow alloc] init]; [theShadow setShadowOffset:NSMakeSize(10.0, -10.0)]; [theShadow setShadowBlurRadius:4.0]; But xcode tell me about NSMakeSize : Sending 'int' to parameter of incompatible type

Put shadow to a rectangle (drawRect:(CGRect)rect)

半城伤御伤魂 提交于 2020-01-06 08:22:06
问题 I did a rectangle with this code and it works: - (void)drawRect:(CGRect)rect{ CGContextRef context = UIGraphicsGetCurrentContext(); CGContextAddRect(context, CGRectMake(60, 60, 100, 1)); CGContextStrokePath(context); } But now i want to put a shadow, I tried with this: NSShadow* theShadow = [[NSShadow alloc] init]; [theShadow setShadowOffset:NSMakeSize(10.0, -10.0)]; [theShadow setShadowBlurRadius:4.0]; But xcode tell me about NSMakeSize : Sending 'int' to parameter of incompatible type

Subclassed UIView shows black background if drawRect: is overridden

家住魔仙堡 提交于 2020-01-06 02:51:12
问题 I have a custom class which I derived from the UIView class. What I want to accomplish is just drawing vertical black lines with a predefined distance between. When I override the drawRect method and write my code to draw vertical lines, the view just shows a complete black background. Then I noticed that even an empty overridden drawRect which only calls the superclass' drawRect results in a black background. When I comment out the drawRect, then the view shows through and becomes

Checking if NSButton is down on drawRect

自闭症网瘾萝莉.ら 提交于 2020-01-03 10:59:08
问题 I would like to check if my custom NSButton is currently in a pressed state (the user is clicking down on it) in my custom drawRect method. Something like this: - (void)drawRect:(NSRect)dirtyRect{ if ([self buttonIsInPressedState]) { [[self alternateBGImage] drawInRect:dirtyRect fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1.0f]; }else{ [[self BGImage] drawInRect:dirtyRect fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1.0f]; } [super drawRect:dirtyRect]; } How

Animate a UIView's CoreGraphics/drawRect content

有些话、适合烂在心里 提交于 2020-01-01 15:47:52
问题 Is it possible to animate a UIView 's CoreGraphics content? Say I have a UIView subclass called MyView that implements the drawRect: method like so: - (void) drawRect: (CGRect) rect { CGContextRef c = UIGraphicsGetCurrentContext(); CGContextSetStrokeColorWithColor(c, someColor); CGContextSetLineWidth(c, someWidth); CGContextMoveToPoint(c, leftOfMyUIView, topOfMyUIView); CGContextAddLineToPoint(c, leftOfMyUIView, bottomOfMyUIView); CGContextStrokePath(c); } In other words - it draws a vertical

How to use drawRect to draw in a existing view?

自古美人都是妖i 提交于 2019-12-30 11:26:27
问题 I'm doing a GPS tracking app. Every time it receives a Latitude/Longitude it converts it to (x,y) coordinates and calls drawRect to draw a line between two (x,y) pairs. However, the drawRect method just clear all the old contents before it draw new thing. How I can make the drawRect to draw new thing on the existing canvas? Thanks in advance here is my viewController.h #import <UIKit/UIKit.h> #import <CoreLocation/CoreLocation.h> @class routetrack; @interface simpleDrawViewController :

How to open a new Intent inside OnTouch Event?

人盡茶涼 提交于 2019-12-30 07:47:46
问题 I have a customized OnTouch Method where i check if the touch coordinates contains a rectangle.After checking the condition i want to start a new Activity.But unfortuanlely its not workin.Can someone help me out? public class custom extends SurfaceView implements SurfaceHolder.Callback{ public boolean onTouchEvent(MotionEvent event) { int touchX = (int) event.getX(); int touchY = (int) event.getY(); switch(event.getAction()){ case MotionEvent.ACTION_DOWN: System.out.println("Touching down!");