Тег ‘UIKit’:

UIImage and Memory

+[UIImage imageNamed:]
• Reads the file, uncompresses it, caches result
• Cached copy of data is kept even if the UIImage is deallocated
• Low memory condition causes cache to be purged.
• No direct control over when cache is purged.
• Use for small frequently drawn images.
+[UIImage imageWithContentsOfFile:]
• Just reads enough of file to determine if it can open [...]

Теги: , , , , , , , ,

Комментарии отсутствуют

Make gradient on iPhone/iPad

It’s easy! As of iPhone SDK 3.0, custom gradients can be implemented very easily, without subclassing or images, by using the new CAGradientLayer
add framework
#import < QuartzCore/QuartzCore.h>

so, example:

Теги: , , , , , ,

Комментарии отсутствуют

Streatch image with stretchableImageWithLeftCapWidth: topCapHeight:

Sample
+ (UIImage*)greenBubble
{
    if (sGreenBubble == nil) {
        UIImage *i = [UIImage imageNamed:@"Balloon_1.png"];
        sGreenBubble = [[i stretchableImageWithLeftCapWidth:15 topCapHeight:13] retain];
    }
    return sGreenBubble;
}
 
+ (UIImage*)grayBubble
{
    if (sGrayBubble == nil) {
        UIImage *i = [UIImage imageNamed:@"Balloon_2.png"];
        sGrayBubble = [[i stretchableImageWithLeftCapWidth:21 topCapHeight:13] retain];
    [...]

Теги: , , , , ,

Комментарии отсутствуют

Custom UINavigationBar with image and back button

Many people could not find this solution! It’s really very simple solution and it does not contain any private methods and functions. It’s based on the drawRect method and the simple manipulation with the title. If the title is specified, then the text of title displays, but if not, then displays the [...]

Теги: , , , , ,

Комментарии отсутствуют

Radio buttons for iPhone application

Presented simple and nice solution for radio buttons, based on the UIButton.
Add buttons on view of controller
for (int i = 0; i < 5; i++) {
        UIButton *but = [UIButton buttonWithType:UIButtonTypeCustom];
        [but setImage:[UIImage imageNamed:@"checkbox.png"] forState:UIControlStateNormal];
        [but setImage:[UIImage imageNamed:@"checkedbox.png"] forState:UIControlStateSelected];
        [but setFrame:CGRectMake(0, 0, 17, [...]

Теги: , , , , , , , ,

Комментариев (2)

Samples code for iPad development from apple

ToolbarSearch
This sample shows how to use a search field in a toolbar. When you start a search, a table view displaying recent searches matching the current search string is displayed in a popover.
New controller:
UIPopoverControllerDelegate

Create a navigation controller to contain the recent searches controller, and create the popover controller to contain the navigation controller.
UINavigationController *navigationController [...]

Теги: , , , , , , ,

Комментарий (1)

Change RGB color of the picture

Change RGB color of the picture
- (UIImage *) changeColor: (UIImage *)image {
    UIGraphicsBeginImageContext(image.size);
   
    CGRect contextRect;
    contextRect.origin.x = 0.0f;
    contextRect.origin.y = 0.0f;
    contextRect.size = [image size];
    // Retrieve source image and begin image context
    CGSize itemImageSize = [image size];
    CGPoint itemImagePosition;
    itemImagePosition.x = ceilf((contextRect.size.width [...]

Теги: , , ,

Комментарии отсутствуют

How to find bug in xCode project of iPhone application.

Теги: , , , , , , , ,

Комментарии отсутствуют

Custom change orientation

Solution for change orientation with uitabbar and others exeptions.
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didOrientation:) name:@"UIDeviceOrientationDidChangeNotification" object:nil];

And method
- (void) didOrientation: (id)object {
   
    UIInterfaceOrientation interfaceOrientation = [[object object] orientation];
 
    if (interfaceOrientation == UIInterfaceOrientationPortrait || interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) {
   
        self.view.transform = CGAffineTransformMakeRotation(0);
    } [...]

Теги: , , , , , ,

Комментарии отсутствуют

How-To: Show/sync volume control in iPod/MediaPlayer

Developing for the iPhone, we wanted to show a volume control that sync’ed with the user’s volume control buttons on the side of the phone. It turns out, the best way to do this is to show the volume control using the MPVolumeView class (part of the MediaPlayer framework).
MPVolumeView *volumeView = [[[MPVolumeView alloc] initWithFrame:
  [...]

Теги: , , ,

Комментарии отсутствуют