ScrollView with scroll’s indicators, which are shown all the time.

UPDATE: This solution could cause some issues on iOS 7. For more detail look .

My simple solution by writing category for UIImageView, because scroller is imageview.

How to use :)
Just setup tag for your scrollview and you will get one with scroll indicators, which are shown all the time.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#define noDisableVerticalScrollTag 836913
#define noDisableHorizontalScrollTag 836914

@implementation UIImageView (ForScrollView)

- (void) setAlpha:(float)alpha {
   
    if (self.superview.tag == noDisableVerticalScrollTag) {
        if (alpha == 0 && self.autoresizingMask == UIViewAutoresizingFlexibleLeftMargin) {
            if (self.frame.size.width < 10 && self.frame.size.height > self.frame.size.width) {
                UIScrollView *sc = (UIScrollView*)self.superview;
                if (sc.frame.size.height < sc.contentSize.height) {
                    return;
                }
            }
        }
    }
   
    if (self.superview.tag == noDisableHorizontalScrollTag) {
        if (alpha == 0 && self.autoresizingMask == UIViewAutoresizingFlexibleTopMargin) {
            if (self.frame.size.height < 10 && self.frame.size.height < self.frame.size.width) {
                UIScrollView *sc = (UIScrollView*)self.superview;
                if (sc.frame.size.width < sc.contentSize.width) {
                    return;
                }
            }
        }
    }
   
    [super setAlpha:alpha];
}
@end

If you want both scroll it’s easy to change code.

Simple EKDemo – EKEvent

Now we have controller for creating events. This controller included from 4.0 iOS SDK.

SimpleEKDemo

The application uses table views to display EKCalendar object and EKEvent objects retrieved from an EKEventStore object. It implements EKEventViewController for viewing and editing existing EKEvents, and uses EKEventEditViewController for creating new EKEvents.

Small feature with UIlabel

Add framework QuartzCore

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#import

UILabel *label = [[UILabel alloc] init];
     [label setTextColor:[UIColor whiteColor]];
     [label setBackgroundColor:[UIColor darkGrayColor]];
     
     [[label layer] setBorderWidth:2];
     [[label layer] setCornerRadius:15];
     [[label layer] setBorderColor:[UIColor whiteColor].CGColor];
     
     [label setAlpha:0.8];
     [label setTextAlignment:UITextAlignmentCenter];
     [label setFrame:CGRectMake(0, 0, 220, 50)];
     [label setText:@"Loading..."];
     [label setCenter:window.center];
     [window addSubview:label];

Result:

Copy UI for additiolan screen

Пример копирования объектов UI на дополнительный экран

Все очень просто, для копирования необходимо выполнить всего 2 метода.

1
2
3
4
5
// copy UI
// archiving data
NSData *archivedData = [NSKeyedArchiver archivedDataWithRootObject: window];
//extract data
externalWindow =  [[NSKeyedUnarchiver unarchiveObjectWithData:archivedData] retain];

Внимание: Интерфейс копируется только без картинок, если будут картинки, то получите креш. Так же скопированные объекты не синхронизированны.

Далее исходники и ролик демострирующий результат…

Continue reading

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 the file.
• Reads and uncompresses the file each time it draws. Uses uncompressed size worth of memory only temporarily.
• Assigning a UIImage created this way to a UIImageView or as the contents of a CALayer also causes it to read and uncompress the file. The UIImageView or CALayer keep the expanded version.
Continue reading

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

1
#import < QuartzCore/QuartzCore.h>

so, example:


Continue reading

Streatch image with stretchableImageWithLeftCapWidth: topCapHeight:

Sample

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
+ (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];
    }
    return sGrayBubble;
}

Results:
Continue reading

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 image.
Continue reading

1 2 3 Next »