¡@

Home 

2014/10/15 ¤U¤È 10:13:12

iphone Programming Glossary: rect

How to make a UITextField move up when keyboard is present

http://stackoverflow.com/questions/1126726/how-to-make-a-uitextfield-move-up-when-keyboard-is-present

nil context NULL UIView setAnimationDuration 0.3 if you want to slide up the view CGRect rect self.view.frame if movedUp 1. move the view's origin up so that the text field that will be hidden.. the keyboard 2. increase the size of the view so that the area behind the keyboard is covered up. rect.origin.y kOFFSET_FOR_KEYBOARD rect.size.height kOFFSET_FOR_KEYBOARD else revert back to the normal.. of the view so that the area behind the keyboard is covered up. rect.origin.y kOFFSET_FOR_KEYBOARD rect.size.height kOFFSET_FOR_KEYBOARD else revert back to the normal state. rect.origin.y kOFFSET_FOR_KEYBOARD..

How to get the RGB values for a pixel on an image on the iphone

http://stackoverflow.com/questions/144250/how-to-get-the-rgb-values-for-a-pixel-on-an-image-on-the-iphone

for rendering will then contain the raw image pixelData in the specified color space. CGRect rect 0 0 self.size.width self.size.height CGContextDrawImage context rect self.CGImage Now we can get a pointer.. specified color space. CGRect rect 0 0 self.size.width self.size.height CGContextDrawImage context rect self.CGImage Now we can get a pointer to the image pixelData associated with the bitmap context. pixelData..

How to customize the background/border colors of a grouped table view cell?

http://stackoverflow.com/questions/400965/how-to-customize-the-background-border-colors-of-a-grouped-table-view-cell

#import CustomCellBackgroundView.h static void addRoundedRectToPath CGContextRef context CGRect rect float ovalWidth float ovalHeight @implementation CustomCellBackgroundView @synthesize borderColor.. frame if self super initWithFrame frame Initialization code return self void drawRect CGRect rect Drawing code CGContextRef c UIGraphicsGetCurrentContext CGContextSetFillColorWithColor c fillColor CGColor.. CGColor if position CustomCellBackgroundViewPositionTop CGContextFillRect c CGRectMake 0.0f rect.size.height 10.0f rect.size.width 10.0f CGContextBeginPath c CGContextMoveToPoint c 0.0f rect.size.height..

How do I size a UITextView to its content?

http://stackoverflow.com/questions/50467/how-do-i-size-a-uitextview-to-its-content

world I then add another line of text Goodbye world Is there a good way in Cocoa Touch to get the rect that will hold all of the lines in the text view so that I can adjust the parent view accordingly As.. this question There is actually a very easy way to do resizing of the UITextView to its correct height of the content. It can be done using the UITextView contentSize . CGRect frame _textView.frame.. _textView.contentSize.height _textView.frame frame One thing to note is that the correct contentSize is only available after the UITextView has been added to the view with addSubview . Prior..

Custom UINavigationBar Background

http://stackoverflow.com/questions/704558/custom-uinavigationbar-background

to overload drawRect like that @implementation UINavigationBar CustomImage void drawRect CGRect rect UIImage image UIImage imageNamed @ NavigationBar.png image drawInRect CGRectMake 0 0 self.frame.size.width..

How to make a UITextField move up when keyboard is present

http://stackoverflow.com/questions/1126726/how-to-make-a-uitextfield-move-up-when-keyboard-is-present

dismissed void setViewMovedUp BOOL movedUp UIView beginAnimations nil context NULL UIView setAnimationDuration 0.3 if you want to slide up the view CGRect rect self.view.frame if movedUp 1. move the view's origin up so that the text field that will be hidden come above the keyboard 2. increase the size of the view so.. up so that the text field that will be hidden come above the keyboard 2. increase the size of the view so that the area behind the keyboard is covered up. rect.origin.y kOFFSET_FOR_KEYBOARD rect.size.height kOFFSET_FOR_KEYBOARD else revert back to the normal state. rect.origin.y kOFFSET_FOR_KEYBOARD rect.size.height kOFFSET_FOR_KEYBOARD.. will be hidden come above the keyboard 2. increase the size of the view so that the area behind the keyboard is covered up. rect.origin.y kOFFSET_FOR_KEYBOARD rect.size.height kOFFSET_FOR_KEYBOARD else revert back to the normal state. rect.origin.y kOFFSET_FOR_KEYBOARD rect.size.height kOFFSET_FOR_KEYBOARD self.view.frame..

How to get the RGB values for a pixel on an image on the iphone

http://stackoverflow.com/questions/144250/how-to-get-the-rgb-values-for-a-pixel-on-an-image-on-the-iphone

image to the bitmap context. The memory allocated for the context for rendering will then contain the raw image pixelData in the specified color space. CGRect rect 0 0 self.size.width self.size.height CGContextDrawImage context rect self.CGImage Now we can get a pointer to the image pixelData associated with the bitmap context... rendering will then contain the raw image pixelData in the specified color space. CGRect rect 0 0 self.size.width self.size.height CGContextDrawImage context rect self.CGImage Now we can get a pointer to the image pixelData associated with the bitmap context. pixelData RGBAPixel CGBitmapContextGetData context return pixelData..

How to customize the background/border colors of a grouped table view cell?

http://stackoverflow.com/questions/400965/how-to-customize-the-background-border-colors-of-a-grouped-table-view-cell

21 08. Copyright 2008 __MyCompanyName__. All rights reserved. #import CustomCellBackgroundView.h static void addRoundedRectToPath CGContextRef context CGRect rect float ovalWidth float ovalHeight @implementation CustomCellBackgroundView @synthesize borderColor fillColor position BOOL isOpaque return NO id initWithFrame.. position BOOL isOpaque return NO id initWithFrame CGRect frame if self super initWithFrame frame Initialization code return self void drawRect CGRect rect Drawing code CGContextRef c UIGraphicsGetCurrentContext CGContextSetFillColorWithColor c fillColor CGColor CGContextSetStrokeColorWithColor c borderColor CGColor.. c fillColor CGColor CGContextSetStrokeColorWithColor c borderColor CGColor if position CustomCellBackgroundViewPositionTop CGContextFillRect c CGRectMake 0.0f rect.size.height 10.0f rect.size.width 10.0f CGContextBeginPath c CGContextMoveToPoint c 0.0f rect.size.height 10.0f CGContextAddLineToPoint c 0.0f rect.size.height..

How do I size a UITextView to its content?

http://stackoverflow.com/questions/50467/how-do-i-size-a-uitextview-to-its-content

I have a UITextView that contains one line of text Hello world I then add another line of text Goodbye world Is there a good way in Cocoa Touch to get the rect that will hold all of the lines in the text view so that I can adjust the parent view accordingly As another example look at the Notes field for events in the Calendar.. in the notes string. iphone cocoa touch uikit share improve this question There is actually a very easy way to do resizing of the UITextView to its correct height of the content. It can be done using the UITextView contentSize . CGRect frame _textView.frame frame.size.height _textView.contentSize.height _textView.frame.. UITextView contentSize . CGRect frame _textView.frame frame.size.height _textView.contentSize.height _textView.frame frame One thing to note is that the correct contentSize is only available after the UITextView has been added to the view with addSubview . Prior to that it is equal to frame.size This will not work if auto..

Custom UINavigationBar Background

http://stackoverflow.com/questions/704558/custom-uinavigationbar-background

objective c share improve this question You just have to overload drawRect like that @implementation UINavigationBar CustomImage void drawRect CGRect rect UIImage image UIImage imageNamed @ NavigationBar.png image drawInRect CGRectMake 0 0 self.frame.size.width self.frame.size.height @end share improve this answer..

How to make a UITextField move up when keyboard is present

http://stackoverflow.com/questions/1126726/how-to-make-a-uitextfield-move-up-when-keyboard-is-present

UIView beginAnimations nil context NULL UIView setAnimationDuration 0.3 if you want to slide up the view CGRect rect self.view.frame if movedUp 1. move the view's origin up so that the text field that will be hidden come above the keyboard.. be hidden come above the keyboard 2. increase the size of the view so that the area behind the keyboard is covered up. rect.origin.y kOFFSET_FOR_KEYBOARD rect.size.height kOFFSET_FOR_KEYBOARD else revert back to the normal state. rect.origin.y.. increase the size of the view so that the area behind the keyboard is covered up. rect.origin.y kOFFSET_FOR_KEYBOARD rect.size.height kOFFSET_FOR_KEYBOARD else revert back to the normal state. rect.origin.y kOFFSET_FOR_KEYBOARD rect.size.height..

How to get the RGB values for a pixel on an image on the iphone

http://stackoverflow.com/questions/144250/how-to-get-the-rgb-values-for-a-pixel-on-an-image-on-the-iphone

allocated for the context for rendering will then contain the raw image pixelData in the specified color space. CGRect rect 0 0 self.size.width self.size.height CGContextDrawImage context rect self.CGImage Now we can get a pointer to the image.. pixelData in the specified color space. CGRect rect 0 0 self.size.width self.size.height CGContextDrawImage context rect self.CGImage Now we can get a pointer to the image pixelData associated with the bitmap context. pixelData RGBAPixel CGBitmapContextGetData..

How to customize the background/border colors of a grouped table view cell?

http://stackoverflow.com/questions/400965/how-to-customize-the-background-border-colors-of-a-grouped-table-view-cell

All rights reserved. #import CustomCellBackgroundView.h static void addRoundedRectToPath CGContextRef context CGRect rect float ovalWidth float ovalHeight @implementation CustomCellBackgroundView @synthesize borderColor fillColor position BOOL.. id initWithFrame CGRect frame if self super initWithFrame frame Initialization code return self void drawRect CGRect rect Drawing code CGContextRef c UIGraphicsGetCurrentContext CGContextSetFillColorWithColor c fillColor CGColor CGContextSetStrokeColorWithColor.. c borderColor CGColor if position CustomCellBackgroundViewPositionTop CGContextFillRect c CGRectMake 0.0f rect.size.height 10.0f rect.size.width 10.0f CGContextBeginPath c CGContextMoveToPoint c 0.0f rect.size.height 10.0f CGContextAddLineToPoint..

How do I size a UITextView to its content?

http://stackoverflow.com/questions/50467/how-do-i-size-a-uitextview-to-its-content

line of text Hello world I then add another line of text Goodbye world Is there a good way in Cocoa Touch to get the rect that will hold all of the lines in the text view so that I can adjust the parent view accordingly As another example look.. uikit share improve this question There is actually a very easy way to do resizing of the UITextView to its correct height of the content. It can be done using the UITextView contentSize . CGRect frame _textView.frame frame.size.height.. _textView.frame frame.size.height _textView.contentSize.height _textView.frame frame One thing to note is that the correct contentSize is only available after the UITextView has been added to the view with addSubview . Prior to that it is equal..

Boundry detect paper sheet opencv

http://stackoverflow.com/questions/13493035/boundry-detect-paper-sheet-opencv

cosine if maxCosine 0.3 squares.push_back approx NSLog @ lu squares.size for size_t i 0 i squares.size i cv Rect rectangle boundingRect Mat squares i if i squares.size 1 Detecting Rectangle here const cv Point p squares i 0 int n int.. 0.3 squares.push_back approx NSLog @ lu squares.size for size_t i 0 i squares.size i cv Rect rectangle boundingRect Mat squares i if i squares.size 1 Detecting Rectangle here const cv Point p squares i 0 int n int squares i .size NSLog.. for size_t i 0 i squares.size i cv Rect rectangle boundingRect Mat squares i if i squares.size 1 Detecting Rectangle here const cv Point p squares i 0 int n int squares i .size NSLog @ d n line image cv Point 507 418 cv Point 507 1776..

libraries to CAPTURE panorama in iOS 6

http://stackoverflow.com/questions/14062932/libraries-to-capture-panorama-in-ios-6

of interest rects indicating where photos overlap Stitcher stitch InputArray images const std vector std vector Rect rois OutputArray pano You can dig into the stitching pipeline to optimise many details of the process but this should be..

iPhone development: pointer being freed was not allocated

http://stackoverflow.com/questions/1424210/iphone-development-pointer-being-freed-was-not-allocated

backing_callback CGContext void CALayer drawInContext UIView CALayerDelegate drawLayer inContext AvatarView drawRect AvatarView overlayPNG UIImageUtility createMaskOf UIGraphicsGetImageFromCurrentImageContext CGBitmapContextCreateImage create_bitmap_data_provider.. i am doing wrong. here's the code of the UIImageUtility createMaskOf function UIImage createMaskOf UIImage source CGRect rect CGRectMake 0 0 source.size.width source.size.height UIGraphicsBeginImageContext CGSizeMake source.size.width source.size.height.. wrong. here's the code of the UIImageUtility createMaskOf function UIImage createMaskOf UIImage source CGRect rect CGRectMake 0 0 source.size.width source.size.height UIGraphicsBeginImageContext CGSizeMake source.size.width source.size.height..

Cropping an image in iOS using OpenCV face detection

http://stackoverflow.com/questions/14756505/cropping-an-image-in-ios-using-opencv-face-detection

mat faces 1.1 2 kHaarOptions cv Size 40 40 And inside the displayfaces functions am cropping with this code CGRect cropRect CGRectMake faces i .x faces i .y faces i .width faces i .width CGImageRef cropped_img CGImageCreateWithImageInRect.. mat faces 1.1 2 kHaarOptions cv Size 40 40 And inside the displayfaces functions am cropping with this code CGRect cropRect CGRectMake faces i .x faces i .y faces i .width faces i .width CGImageRef cropped_img CGImageCreateWithImageInRect self.storeImage.CGImage.. 1.1 2 kHaarOptions cv Size 40 40 And inside the displayfaces functions am cropping with this code CGRect cropRect CGRectMake faces i .x faces i .y faces i .width faces i .width CGImageRef cropped_img CGImageCreateWithImageInRect self.storeImage.CGImage..

How to style UITextview to like Rounded Rect text field?

http://stackoverflow.com/questions/1824463/how-to-style-uitextview-to-like-rounded-rect-text-field

to style UITextview to like Rounded Rect text field I am using a text view as a comment composer. In the properties inspector I can't find anything like a border.. I add a UITextView in code it will work if it's added in IB too UITextView textView UITextView alloc initWithFrame CGRectMake 50 220 200 100 To make the border look very close to a UITextField textView.layer setBorderColor UIColor grayColor colorWithAlphaComponent..

How to get image from FileAttachment Annotation in pdf file

http://stackoverflow.com/questions/18574559/how-to-get-image-from-fileattachment-annotation-in-pdf-file

Annots outputArray pdfAnnots release return nil CGPDFArrayRef rectArray if CGPDFDictionaryGetArray annotDict Rect rectArray break int arrayCount CGPDFArrayGetCount rectArray CGPDFReal coords 4 for int k 0 k arrayCount k CGPDFObjectRef.. break CGPDFReal coord if CGPDFObjectGetValue rectObj kCGPDFObjectTypeReal coord break coords k coord CGRect rect CGRectMake coords 0 coords 1 coords 2 coords 3 NSLog @ @ NSStringFromCGRect rect Update CGPDFDictionaryRef aDict if.. CGPDFReal coord if CGPDFObjectGetValue rectObj kCGPDFObjectTypeReal coord break coords k coord CGRect rect CGRectMake coords 0 coords 1 coords 2 coords 3 NSLog @ @ NSStringFromCGRect rect Update CGPDFDictionaryRef aDict if CGPDFDictionaryGetDictionary..

Setting A CGContext Transparent Background

http://stackoverflow.com/questions/2125543/setting-a-cgcontext-transparent-background

struggling with drawing a line with CGContext. I have actually go to line to draw but now I need the background of the Rect to be transparent so the existing background shows thru. Here's my test code void drawRect CGRect rect CGContextRef context.. need the background of the Rect to be transparent so the existing background shows thru. Here's my test code void drawRect CGRect rect CGContextRef context UIGraphicsGetCurrentContext CGContextSetFillColorWithColor context UIColor clearColor .CGColor.. background of the Rect to be transparent so the existing background shows thru. Here's my test code void drawRect CGRect rect CGContextRef context UIGraphicsGetCurrentContext CGContextSetFillColorWithColor context UIColor clearColor .CGColor..

Custom ProgressBar widget

http://stackoverflow.com/questions/3841231/custom-progressbar-widget

this addView mSlider fl.addView mSlider addView fl @Override protected void onDraw Canvas canvas super.onDraw canvas Rect rectf new Rect mSlider.getLocalVisibleRect rectf Log.d WIDTH String.valueOf rectf.width Log.d HEIGHT String.valueOf rectf.height.. mSlider fl.addView mSlider addView fl @Override protected void onDraw Canvas canvas super.onDraw canvas Rect rectf new Rect mSlider.getLocalVisibleRect rectf Log.d WIDTH String.valueOf rectf.width Log.d HEIGHT String.valueOf rectf.height Log.d.. fl @Override protected void onDraw Canvas canvas super.onDraw canvas Rect rectf new Rect mSlider.getLocalVisibleRect rectf Log.d WIDTH String.valueOf rectf.width Log.d HEIGHT String.valueOf rectf.height Log.d left String.valueOf rectf.left..

Fast and Lean PDF Viewer for iPhone / iPad / iOs - tips and hints?

http://stackoverflow.com/questions/3889634/fast-and-lean-pdf-viewer-for-iphone-ipad-ios-tips-and-hints

the DocRef and any page Caches Other PDF Features Getting Links inside a PDF and here and here Understanding the PDF Rect for link positioning Converting PDF annot datestrings Getting the target of the link Getting the page number from the Dest.. CGSize imageSize CGSizeMake baseImage.size.width imageScaleFactor baseImage.size.height imageScaleFactor CGRect imageRect CGRectMake self.bounds.size.width imageSize.width 2 self.bounds.size.height imageSize.height 2 imageSize.width.. CGSize imageSize CGSizeMake baseImage.size.width imageScaleFactor baseImage.size.height imageScaleFactor CGRect imageRect CGRectMake self.bounds.size.width imageSize.width 2 self.bounds.size.height imageSize.height 2 imageSize.width imageSize.height..

Get PDF hyperlinks on iOS with Quartz

http://stackoverflow.com/questions/4080373/get-pdf-hyperlinks-on-ios-with-quartz

CGPDFDictionaryGetString aDict URI uriStringRef return CGPDFArrayRef rectArray if CGPDFDictionaryGetArray annotDict Rect rectArray return int arrayCount CGPDFArrayGetCount rectArray CGPDFReal coords 4 for int k 0 k arrayCount k CGPDFObjectRef.. CGPDFStringGetBytePtr uriStringRef NSString uri NSString stringWithCString uriString encoding NSUTF8StringEncoding CGRect rect CGRectMake coords 0 coords 1 coords 2 coords 3 CGPDFInteger pageRotate 0 CGPDFDictionaryGetInteger pageDictionary Rotate.. uriStringRef NSString uri NSString stringWithCString uriString encoding NSUTF8StringEncoding CGRect rect CGRectMake coords 0 coords 1 coords 2 coords 3 CGPDFInteger pageRotate 0 CGPDFDictionaryGetInteger pageDictionary Rotate pageRotate..

Gesture recognizer and button actions

http://stackoverflow.com/questions/4825199/gesture-recognizer-and-button-actions

a view hierarchy that looks something like this UIView A UIView UIImageView UIView UIView B UIView UIView B Rounded Rect Button UIView UIView B UIImageView UIView UIView B UILabel I've attached gesture recognizer s to my UIView B . The problem.. gesture recognizer s to my UIView B . The problem that i'm facing is that i don't get any actions for the Rounded Rect Button which is inside the UIView B . The singleTap gesture recognizer captures overrides the button's Touch Up Inside event...

sample code for collision detection in iPhone sdk

http://stackoverflow.com/questions/5620510/sample-code-for-collision-detection-in-iphone-sdk

views being named img_view1 and img_view2 . Image views creation For img_view1 rect parameters are x y width height CGRect image_rect1 CGRectMake img_view1.position.x img_view1.position.y 100 100 For img_view2 rect parameters are x y width height.. img_view1 and img_view2 . Image views creation For img_view1 rect parameters are x y width height CGRect image_rect1 CGRectMake img_view1.position.x img_view1.position.y 100 100 For img_view2 rect parameters are x y width height CGRect image_rect2.. CGRectMake img_view1.position.x img_view1.position.y 100 100 For img_view2 rect parameters are x y width height CGRect image_rect2 CGRectMake img_view2.position.x img_view2.position.y 100 100 Collision detection if CGRectIntersectsRect image_rect1..

Draw Line with gesture

http://stackoverflow.com/questions/6436990/draw-line-with-gesture

image I had look on How to draw graphics in iphone gesture But I couldn't apply it on the subview specially the DrawInRect method in panRecognizer function move I want to draw line using UIPanGestureRecognizer gR UIPanGestureRecognizer sender.. NSLog @ End of measuring and I will use the points in Points to draw line above all the subviews in void drawRect CGRect rect NSLog @ Entered Draw In Rect if Measuring UIColor redColor setStroke UIBezierPath pathToDraw UIBezierPath bezierPath.. NSLog @ End of measuring and I will use the points in Points to draw line above all the subviews in void drawRect CGRect rect NSLog @ Entered Draw In Rect if Measuring UIColor redColor setStroke UIBezierPath pathToDraw UIBezierPath bezierPath..

How to mask an image in IOS sdk?

http://stackoverflow.com/questions/9872975/how-to-mask-an-image-in-ios-sdk

CGContextSetBlendMode ctx kCGBlendModeNormal CGContextSetFillColorWithColor ctx UIColor whiteColor .CGColor NSLog @ Rect @ CGContextGetClipBoundingBox ctx CGImageRef alphaMask CGBitmapContextCreateImage ctx CGContextClipToMask ctx CGContextGetClipBoundingBox.. ctx CGContextClipToMask ctx CGContextGetClipBoundingBox ctx alphaMask draw in context you can use also drawInRect withFont text drawAtPoint CGPointMake 0.0 0.0 withFont font transfer image UIImage image UIGraphicsGetImageFromCurrentImageContext..