drawrect

Custom UITableViewCell and animation on setSelected:animated:

会有一股神秘感。 提交于 2019-12-21 05:43:13
问题 I have a UITableViewCell subclass that does its drawing in a drawRect: method. The whole rectangle is custom drawn, including the background. I was able to get very complex cells while keeping the scrolling very smooth. My problem: I call [table deselectRowAtIndexPath:path animated:YES]; whenever the view appears, in order to comply with Apple's HIG. However, no animation occurs. It worked when I had a custom view (created with subviews) that was transparent (so Apple's background would

Using circular progress bar with masked image?

时光毁灭记忆、已成空白 提交于 2019-12-21 01:40:07
问题 I am working on a circular progress bar for custom game center achievements view and I have kind of "hit the wall". I am struggling with this for over two hours and still cannot get it to work. The thing is, that I need a circular progress bar, where I would be able to set (at least) the track(fill) image. Because my progress fill is a rainbow like gradient and I am not able to achieve the same results using only code. I was messing with CALayers, and drawRect method, however I wasn't

iOS Drawing Circles

落花浮王杯 提交于 2019-12-21 01:09:48
问题 I am trying to create the circles below in my iOS app. I know how to make the circles but am not entirely sure on how to get the points along the arc. It has to be in code not an image. Below is also the code I currently have. - (void)drawRect:(CGRect)rect { CGPoint point; point.x = self.bounds.origin.x + self.bounds.size.width/2; point.y = self.bounds.origin.y + self.bounds.size.height/2; CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSetLineWidth(context, 2.0);

Drawing colored text in UIView's -drawRect: method

人走茶凉 提交于 2019-12-20 17:42:26
问题 I am trying to draw colored text in my UIView subclass. Right now I am using the Single View app template (for testing). There are no modifications except the drawRect: method. The text is drawn but it is always black no matter what I set the color to. - (void)drawRect:(CGRect)rect { UIFont* font = [UIFont fontWithName:@"Arial" size:72]; UIColor* textColor = [UIColor redColor]; NSDictionary* stringAttrs = @{ UITextAttributeFont : font, UITextAttributeTextColor : textColor };

Drawing colored text in UIView's -drawRect: method

£可爱£侵袭症+ 提交于 2019-12-20 17:39:59
问题 I am trying to draw colored text in my UIView subclass. Right now I am using the Single View app template (for testing). There are no modifications except the drawRect: method. The text is drawn but it is always black no matter what I set the color to. - (void)drawRect:(CGRect)rect { UIFont* font = [UIFont fontWithName:@"Arial" size:72]; UIColor* textColor = [UIColor redColor]; NSDictionary* stringAttrs = @{ UITextAttributeFont : font, UITextAttributeTextColor : textColor };

CALayer vs CGContext, which is a better design approach?

夙愿已清 提交于 2019-12-20 10:37:17
问题 I have been doing some experimenting with iOS drawing. To do a practical exercise I wrote a BarChart component. The following is the class diagram (well, I wasnt allowed to upload images) so let me write it in words. I have a NGBarChartView which inherits from UIView has 2 protocols NGBarChartViewDataSource and NGBarChartViewDelegate. And the code is at https://github.com/mraghuram/NELGPieChart/blob/master/NELGPieChart/NGBarChartView.m To draw the barChart, I have created each barChart as a

Stop NSView drawRect clearing before drawing? (lockFocus no longer working on macOS 10.14)

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-20 03:52:38
问题 I have an animation using two views where I would call lockFocus and get at the graphics context of the second NSView with [[NSGraphicsContext currentContext] graphicsPort], and draw. That worked fine until macOS 10.14 (Mojave). Found a reference here: https://developer.apple.com/videos/play/wwdc2018/209/ At 22:40 they talk about the "legacy" backing store that has changed. The above lockFocus and context pattern was big on the screen, saying that that won't work any more. And that is true.

drawRect:/renderInContext: issues

送分小仙女□ 提交于 2019-12-19 11:55:07
问题 Seem to be having a bit of an issue trying to draw my view into a context. My basic setup is, I have a view controller that owns a UIPageViewController in which I load controllers with views that can be drawn on by the users finger. Basically I have a book that can be drawn in. When the page is turned in the book I save the image by calling - (UIImage *)wholeImage { // Render the layer into an image and return UIGraphicsBeginImageContext(self.bounds.size); [self.layer renderInContext

UIGraphicsGetCurrentContext() short lifetime

限于喜欢 提交于 2019-12-19 10:11:41
问题 I have a view which implements freehand drawing, but I have a small problem. I noticed on the iPad 3 that everything went to hell, so I tried to update my drawing code (probably as I should have done in the first place) to only update the portion that was stroked. However, the first stroke after open, and the first stroke after about 10 seconds of idle are extremely slow. After everything is "warmed up" it is smooth as butter and only takes about 0.15ms per drawRect. I don't know why, but the

Finding an angle with 3 CGPoints

▼魔方 西西 提交于 2019-12-18 18:31:11
问题 In my application, a user taps 3 times and an angle will be created by the 3 points that were tapped. It draws the angle perfectly. I am trying to calculate the angle at the second tap, but I think I am doing it wrong (probably a math error). I haven't covered this in my calculus class yet, so I am going off of a formula on wikipedia. http://en.wikipedia.org/wiki/Law_of_cosines Here is what I am trying: Note: First, Second, and Third are CGPoints created at the user's tap. CGFloat xDistA =