quartz-graphics

Setting multiple borders on UIView

ぃ、小莉子 提交于 2019-12-30 11:02:21
问题 As I cannot find any questions/answers for this, I imagine it is not possible. Is there anyway to set multiple borders on a UIView . I am currently setting a standard border with .layer.borderWidth and layer.borderColor . I am wondering if I can add a multiple strokes/borders effect to the view. I need a border of 4.0f in white then another 1.0f in another color. 回答1: Three solutions I can think of: nest a UIView in another one, define one border for each; draw the border yourself in -(void

iPhone clip image with path

淺唱寂寞╮ 提交于 2019-12-29 06:25:10
问题 I would like to clip an image with path. In the book Programming with Quartz there is an example on how to draw a circle clipped by a rectangular path (p.37), and there is also a chapter on image masking with existing image as stencil (Ch.10). But I'm still not sure about how to clip an existing image using path. Is there any example or pointer? 回答1: Here is a sample that should work, it sets the clipping area as a path(this path in my case is an elipse, you could use a rect). Then the image

CGEventPost - possible bug when simulating keyboard events?

 ̄綄美尐妖づ 提交于 2019-12-28 02:39:09
问题 I have a very simple chunk of code that is designed to simulate keyboard events. The simple example below should type "Cz" - the shift key goes down, the c key goes down, c comes up and shift comes up. Then the z key goes down and up. It seems that sometimes the order gets muddled though. When I create a timer to call this routine every second, the output should be CzCzCzCz.... But here's what I get: CZcZCZCzczCzczCzczCZCZCzCz I'll run it again: CzCzCzCzCZCzCZCzCZCzCZCzCZCzCzCz Different. And

Rotating NSString in Swift

≡放荡痞女 提交于 2019-12-25 10:23:06
问题 I'm trying to do something like the attached image. I thought this page would lead to the answer http://www.informit.com/articles/article.aspx?p=2149190&seqNum=13 or Rotating a NSString in drawRect Drawing rotated text with NSString drawInRect but converting objC to swift is troublesome. I can easily draw my arrows but getting the NSString to rotate then translate is problematic. It does weird things like drawing off screen, wrong angles, etc. I've tried this and many variations

Rotating NSString in Swift

拈花ヽ惹草 提交于 2019-12-25 10:19:32
问题 I'm trying to do something like the attached image. I thought this page would lead to the answer http://www.informit.com/articles/article.aspx?p=2149190&seqNum=13 or Rotating a NSString in drawRect Drawing rotated text with NSString drawInRect but converting objC to swift is troublesome. I can easily draw my arrows but getting the NSString to rotate then translate is problematic. It does weird things like drawing off screen, wrong angles, etc. I've tried this and many variations

CGContext transformation, to extract rotated rect

倾然丶 夕夏残阳落幕 提交于 2019-12-25 04:49:15
问题 My intention is to write a function which can extract a rotated rectangular portion of a larger image. That rotated rectangular portion is described with a center point (from 0,0 to full image width/height) a size, and a rotation angle. I worry that I'm not understanding something about CGContexts. I know that after a rotation, my coordinate space is rotated. This function always works if the angle is 0 and appears to be correct if the angle is small. However, as the angle increases,

register for WindowServer CGScreenRefreshCallback CGScreenUpdateMoveCallback in C++

六眼飞鱼酱① 提交于 2019-12-25 01:55:27
问题 I'm trying to register for CGScreenRefreshCallback and CGScreenUpdateMoveCallback ( here's what apple's saying about http://developer.apple.com/mac/library/documentation/GraphicsImaging/Reference/Quartz_Services_Ref/Reference/reference.html#//apple_ref/doc/uid/TP30001070-CH1g-F16970 ) using C++ only. I wrote this simple tester for the refresh callback in order to retrieve the changing rectangles: #include "ApplicationServices/ApplicationServices.h" #include <iostream> using namespace std; ///

32 bit/component Images with CGImageCreate are actually only 8 bit/component

[亡魂溺海] 提交于 2019-12-24 09:09:13
问题 For the past 4 to 5 hours I've been wrestling with this very bizarre issue. I have a an array of bytes which contain pixel values out of which I'll like to make an image of. The array represents 32 bit per component values. There is no Alpha channel, so the image is 96 bits/pixel. I have specified all of this to the CGImageCreate function as follows: CGImageRef img = CGImageCreate(width, height, 32, 96, bytesPerRow, space, kCGImageAlphaNone , provider, NULL, NO, kCGRenderingIntentDefault);

Not drawing outside bounds when clipToBounds=NO

牧云@^-^@ 提交于 2019-12-23 18:37:23
问题 I am drawing lines on a map, and I notice that my annotation view isn't covering the entire area of the lines (which is fine, as long as I can draw outside the bounds of the view). Here is a picture of what I'm experiencing. The clipToBounds property is set to NO for the annotation view, and I've added a semi-transparent color to the background so you can see the position of the view. blue line not drawn outside bounds http://img.skitch.com/20100512-qdm18j7x42wptw3cumnr6h271q.jpg The pins

Autorelease for CGMutablePathRef?

我是研究僧i 提交于 2019-12-23 18:03:57
问题 I am developing for iphone. I want to creating a mutable path via CGPathCreateMutable(), and I want to return it out of the function which creates it. I'm suppose to call a CGPathRelease() when I'm done with it. But since I'm returning it I wish to autorelease it. Since Quartz path is a C code (and doesn't look like an objective C object), is it correct that I cannot call autorelease on it? Edit: For others who stumble upon this question, the below advise is for C functions returning Core