drawrect

Drawing animation

徘徊边缘 提交于 2019-12-02 18:38:09
I'm creating a simple app where when the user presses a button, a series of lines will be drawn on the screen and the user will be able to see these lines drawn in real time (almost like an animation). My code looks something like this (has been simplified): UIGraphicsBeginImageContext(CGSizeMake(300,300)); CGContextRef context = UIGraphicsGetCurrentContext(); for (int i = 0; i < 100; i++ ) { CGContextMoveToPoint(context, i, i); CGContextAddLineToPoint(context, i+20, i+20); CGContextSetStrokeColorWithColor(context, [[UIColor blackColor] CGColor]); CGContextStrokePath(context); } UIImage

A red rectangle drawn on 2D texture disappears right after being drawn

懵懂的女人 提交于 2019-12-02 09:42:12
following my another question , I have provided the code that draws the rectangle as follows: void COpenGLControl::DrawRectangleOnTopOfTexture() { wglMakeCurrent(hdc, hrc); glPushAttrib(GL_ENABLE_BIT|GL_CURRENT_BIT); glDisable(target); glColor3f(1.0f,0.0f,0.0f); glBegin(GL_LINE_LOOP); glVertex2f(RectangleToDraw.at(0),RectangleToDraw.at(1)); glVertex2f(RectangleToDraw.at(0),RectangleToDraw.at(3)); glVertex2f(RectangleToDraw.at(2),RectangleToDraw.at(3)); glVertex2f(RectangleToDraw.at(2),RectangleToDraw.at(1)); glEnd(); glPopAttrib(); SwapBuffers(hdc); wglMakeCurrent(NULL, NULL); } void

Any possible way to call drawRect from a UIViewcontroller class?

旧街凉风 提交于 2019-12-02 03:39:56
I have a UIViewController class called AppController.h , AppController.m . I have thousands of lines of code in there, and that is the only reason why I didn't test this before I asked it. Is there any possible way to use drawRect in a UIViewController ? that way I wouldn't have to make more delegates and methods and callbacks. I should have started off using drawRect to handle my drawing code, but I didn't, and there's severe lag with core graphics on the iPad. So, please let me know if there's any way to use drawRect in a UIViewController . Thanks! A view controller naturally has a pointer

Autolayout constraints do no work for NSView composition with drawRect:

淺唱寂寞╮ 提交于 2019-12-02 02:26:02
问题 I am trying to apply Autolayout constraints to a custom button which inherits from NSView . The button is rather complex and can be used as radio button for example. The user interface is composed in drawRect: as you can guess from the following code excerpt. @interface CustomButton : NSView ... - (void)drawRect:(NSRect)dirtyRect { // ... if (self.hasImage) { // ... if (self.hasTitle) { // ... [image drawInRect:imgRect fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:fraction

drawRect:/renderInContext: issues

谁都会走 提交于 2019-12-01 14:37:14
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()]; UIImage *wholePageImage = UIGraphicsGetImageFromCurrentImageContext();

UISearchBar: Changing the appearance - Shape, Background, Overlay an Image

六月ゝ 毕业季﹏ 提交于 2019-12-01 13:23:02
I'd like to change the appearance of the default UISearchBar. As an example, how would you recreate the search box in the Google iPhone app as seen below? How would you overlay an image to produce this effect? (source: isedb.com ) Upon some investigating of possibilites to customize the search bar, I'm inclined to say this is a custom component that has nothing to do with UISearchBar , but instead recreates its functionality. You don't need to subclass anything. Create a new UIView that has the buttons and text field and then when then entire view is going to load do this: [self

UISearchBar: Changing the appearance - Shape, Background, Overlay an Image

僤鯓⒐⒋嵵緔 提交于 2019-12-01 11:18:19
问题 I'd like to change the appearance of the default UISearchBar. As an example, how would you recreate the search box in the Google iPhone app as seen below? How would you overlay an image to produce this effect? (source: isedb.com) 回答1: Upon some investigating of possibilites to customize the search bar, I'm inclined to say this is a custom component that has nothing to do with UISearchBar , but instead recreates its functionality. 回答2: You don't need to subclass anything. Create a new UIView

How to use drawRect to draw in a existing view?

女生的网名这么多〃 提交于 2019-12-01 11:11:51
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 : UIViewController <CLLocationManagerDelegate> { CLLocationManager *locationManager; IBOutlet routetrack

UIGraphicsGetCurrentContext() short lifetime

隐身守侯 提交于 2019-12-01 10:28:39
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 whole view rectangle is getting marked as dirty for the first drawRect, and the first drawRect after

drawRect over subviews?

末鹿安然 提交于 2019-12-01 02:42:11
问题 I created a container view that holds a bunch of child views - a collection view, a custom toolbar and some bits and pieces. The design has a border on the top, left and right sides, but not the bottom, so I overrode drawRect to include border. When I added the toolbar I noticed that it appears over the top of the border. (For some reason I initially thought it wouldn't but of course it does!). Is there anyway I can tell drawRect to draw over the top of my subviews? Of course there's loads of