quartz-graphics

Using Multiple CGAffineTransforms On Text Matrix

我的未来我决定 提交于 2019-12-10 17:11:26
问题 I am displaying text using Quartz. Here is my code: CGContextRef myContext = UIGraphicsGetCurrentContext(); CGContextSelectFont(myContext, "Helvetica", 12, kCGEncodingMacRoman); CGContextSetCharacterSpacing(myContext, 8); CGContextSetTextDrawingMode(myContext, kCGTextFillStroke); CGContextSetRGBFillColor(myContext, 0, 0, 0, 1); CGContextSetRGBStrokeColor(myContext, 0, 0, 0, 1); CGContextSetTextMatrix(myContext,CGAffineTransformMake(1, 0, 0, -1, 0, 0)); CGContextShowTextAtPoint(myContext,

Quartz based drop shadows don't work for me on UITextView

浪尽此生 提交于 2019-12-10 15:44:56
问题 I have been able to add shadows to many UI objects in my view, including rather nicely drop shadowing some custom drawing in a UIImageView. However the same code produces nothing when applied to a UITextView: [desc.layer setShadowColor:[[UIColor blackColor] CGColor]]; [desc.layer setShadowRadius:2.0f]; [desc.layer setShadowOffset:CGSizeMake(1, 1)]; [desc.layer setShadowOpacity:0.8f]; Is this something I'm missing? I was hoping to use quartz to add a border and a drop shadow. The border code

How to add shadow to a transparent UIView?

旧街凉风 提交于 2019-12-10 13:17:47
问题 How can I reproduce this shadowing? My problem, that if I use high alpha color or clearColor, there is no drop shadow, if I use low alpha color, I can't see the drop shadow under the plate. As the level of the volume is changing (colorful part) the shadow is moving also, so it is not pure Photoshop. 回答1: try something using thoses properies of your view. it might end up with something view.layer.shadowColor = [UIColor colorWithWhite:.5 alpha:1].CGColor; view.layer.shadowRadius = 4.0f; view

Why am I not getting a grey background in this program

本秂侑毒 提交于 2019-12-10 12:15:23
问题 I followed the tutorial on this page: http://iphone-3d-programming.labs.oreilly.com/ch01.html I got down to the part where it says, "Compile and build and you should now see a solid gray screen. Hurray!" However, when I ran the program, I just get a black screen. These are what the files look like: HelloArrowAppDelegate.h #import <UIKit/UIKit.h> #import "GLView.h" @interface HelloArrowAppDelegate : NSObject <UIApplicationDelegate> { UIWindow *m_window; GLView* m_view; } @end

iPhone CALayer animation

倖福魔咒の 提交于 2019-12-10 11:58:25
问题 I am drawing a line animation, connecting 2 points with a line. This is my code: -(void) drawObject{ rootLayer = [CALayer layer]; rootLayer.frame = self.view.bounds; [self.view.layer addSublayer:rootLayer]; lineStartPath = CGPathCreateMutable(); CGPathMoveToPoint(lineStartPath, nil, 160, 50); CGPathAddLineToPoint(lineStartPath, nil, 160, 50); CGPathCloseSubpath(lineStartPath); lineEndPath = CGPathCreateMutable(); CGPathMoveToPoint(lineEndPath, nil, 160, 50); CGPathAddLineToPoint(lineEndPath,

Using CGEventTapCreate Trouble with parameters in Swift

不问归期 提交于 2019-12-10 11:29:41
问题 I am trying to trap keypresses using a CGEventTapCreate etc in Swift. I want to do this so that when my toddler is using a program the Mac, I can limit which keys do something. I appreciate that I need to enable assistive technology to get CGEventTap to work I am having trouble understanding what I need to do in Swift to get the final parameter in the call. Essentially, I do not understand part of the documentation at quartz event documentation Specifically the final parameter which is

Is it possible to detect if Magic Mouse/Trackpad is being touched?

心不动则不痛 提交于 2019-12-10 10:25:16
问题 Just wondering if there is a way to receive a callback in Cocoa if Magic Mouse or Trackpad is being touched by the user? I looked into Quartz Events, but it seems I can only get callbacks if the mouse is moving or clicked etc. Note that I want to receive a callback even if my app is not active. It's a background utility app. Also, it can't use private frameworks as it's going to be a Mac App Store app. 回答1: You could use this code to trap the events: (create a new Cocoa application and put

How to draw a triangle with QUARTZ 2D?

做~自己de王妃 提交于 2019-12-09 23:41:07
问题 I'm developing an iPhone app with 3.1.3 SDK. I'm trying to draw a triangle with transparent fill an 1px black stroke with this code: CGContextMoveToPoint(ctx, position.X, position.Y - (size.height / 2)); CGContextAddLineToPoint(ctx, position.X - (size.width / 2), position.Y + (size.height / 2)); CGContextAddLineToPoint(ctx, position.X + (size.width / 2), position.Y + (size.height / 2)); CGContextFillPath(ctx); CGContextSetLineWidth(ctx, 1.0); CGContextStrokePath(ctx);

CGEventPostToPSN() not working for mouse clicking

自古美人都是妖i 提交于 2019-12-09 19:27:33
问题 I need to send mouse click events to an arbitrary process (not necessarily the front one) without bringing that process's window to the front. This code works for sending a mouse click and letting the window server send it to whatever process it decides has focus: #include <ApplicationServices/ApplicationServices.h> int main() { CGEventRef down, up; down = CGEventCreateMouseEvent( NULL, kCGEventLeftMouseDown, CGPointMake(16, 36), kCGMouseButtonLeft ); up = CGEventCreateMouseEvent( NULL,

ImageQuality with CGContextSetInterpolationQuality

落花浮王杯 提交于 2019-12-09 13:25:01
问题 How effective is the CGContextSetInterpolationQuality method in Quartz? Does it affect the quality of the image? If so, to what extent? I can't see any difference between the interpolated and the non-interpolated image. 回答1: Although this is a bit of an old question, I have recently done some benchmarking about the effects of CGContextSetInterpolationQuality and thought that its outcomes might be of interest to someone else. In my benchmark test, I draw a set of 6 different 649x649 b&w bitmap