Hq replica handbags UIColor from hex

I added 2 new methods to category UIColor.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+ (UIColor* ) colorWithHex:(int)color {

    float red = (color & 0xff000000) >> 24;
    float green = (color & 0x00ff0000) >> 16;
    float blue = (color & 0x0000ff00) >> 8;
    float alpha = (color & 0x000000ff);

    return [UIColor colorWithRed:red/255.0 green:green/255.0 blue:blue/255.0 alpha:alpha/255.0];
}

+ (UIColor *) colorWithHexRed:(int)red green:(char)green blue:(char)blue alpha:(char)alpha {
    int x = 0;
    x |= (red & 0xff) << 24;
    x |= (green & 0xff) << 16;
    x |= (blue & 0xff) << 8;
    x |= (alpha & 0xff);
    return [UIColor colorWithHex:x];
}

Example:

1
UIColor *redColor = [UIColor colorWithHex:0xff0000ff];

First 6 symbols like HTML color, latest 2 symbols it’s alpha.

Tags hq replica: , ,

Leave a Comment

1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 4.00 out of 5)

Loading ... Loading ...

 

GLKit and MSAA

Enable MSAA Anti-Aliasing in GLKit.

Just enable:

1
2
GLKView *view = (GLKView *)self.view;
view.drawableMultisample = GLKViewDrawableMultisample4X;

Without MSAA:

 

With MSAA:

GLKit_MSAA_Sample

Tags: , , , , ,

Leave a Comment

1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 5.00 out of 5)

Loading ... Loading ...

 

Distance between vertices and magnitude of a vector

Distance between vertices:

1
2
3
4
5
6
7
8
9
10
11
12
13
static inline GLfloat Vertex3DDistanceBetweenVertices
(Vertex3D vertex1, Vertex3D vertex2)
{
    GLfloat deltaX, deltaY, deltaZ;

    deltaX = vertex2.x - vertex1.x;
    deltaY = vertex2.y - vertex1.y;
    deltaZ = vertex2.z - vertex1.z;

    return sqrtf((deltaX * deltaX) +
        (deltaY * deltaY) +
        (deltaZ * deltaZ));
}

Magnitude of a vector:

1
2
3
4
5
6
static inline GLfloat Vector3DMagnitude(Vector3D vector)
{
    return sqrtf((vector.x * vector.x) +
        (vector.y * vector.y) +
        (vector.z * vector.z));
}

Tags: , ,

Leave a Comment

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)

Loading ... Loading ...

 

The Terminology of the Basic Trigonometric Functions high quality replica handbags

Function C function Definition
Sine sinf() The ratio of the length of the opposite to the length of high quality replica handbags the hypotenuse
Cosine cosf() The ratio of the length of the adjacent to the length of the hypotenuse
Tangent tanf() The ratio of the length of the opposite to the length of the adjacent

Leave a Comment

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)

Loading ... Loading ...

 

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

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.

Tags: , , , , , , , , , ,

Leave a Comment

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)

Loading ... Loading ...

 

AVPlayer – looping video without “hiccup”/delays

I tried create loop by AVQueuePlayer, this method has delays between end and start play.

for looping AVQueuePlayer i use this code:

1
2
3
4
5
6
[[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(playerItemDidReachEnd:)
                                                 name:AVPlayerItemDidPlayToEndTimeNotification
                                               object:self.mPlayerItem];
     
    [self player].actionAtItemEnd = AVPlayerActionAtItemEndNone;

and playerItemDidReachEnd

1
2
3
4
5
- (void)playerItemDidReachEnd:(NSNotification *)notification
{
    AVPlayerItem *p = [notification object];
    [p seekToTime:kCMTimeZero];
}

Another solution without hiccups/delays based on AVMutableComposition!
[Read more...]

Tags: , , , , , , , , ,

Leave a Comment

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)

Loading ... Loading ...

 

AudioSession AudioRouteChange

if you will use or used AVPlayer or you want just know about changes, you can check AudioRouteChange.

Simple solution:

Add framework AudioToolbox and add import to file

1
#import <AudioToolbox/AudioToolbox.h>

Insert into init method or any other

1
AudioSessionAddPropertyListener (kAudioSessionProperty_AudioRouteChange, callbackHeadphone_func, self);

Listener callback

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
void callbackHeadphone_func ( void *inClientData, AudioSessionPropertyID inID, UInt32 inDataSize, const void *inData ) {
    if ( inID == kAudioSessionProperty_AudioRouteChange ) {
        [mainViewController performSelector:@selector(isHeadsetPluggedIn)];
    }
}


- (void) isHeadsetPluggedIn {
   
    UInt32 routeSize = sizeof (CFStringRef); CFStringRef route;
   
    AudioSessionGetProperty (kAudioSessionProperty_AudioRoute, &routeSize, &route);
      /* Known values of route:
     "Headset"
     "Headphone"
     "Speaker"
     "SpeakerAndMicrophone"
     "HeadphonesAndMicrophone"
     "HeadsetInOut"
     "ReceiverAndMicrophone"
     "Lineout" */

   
    NSString* routeStr = (NSString*)route;
    DLog(@"%@",routeStr);
}

Tags: , , ,

Leave a Comment

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)

Loading ... Loading ...

 

NSRegularExpression sample for comment syntax highlighting

I have this text:

1
word1 word2 " word3 //" word4

I wrote simple solution. I know it can be better. I know about Back Reference, but i don’t have experience with it.

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
33
NSRegularExpression *expression = [NSRegularExpression regularExpressionWithPattern:@"((@\"|\").*?(\"))"
                                          options:NSRegularExpressionDotMatchesLineSeparators
                                            error:nil];
NSArray *textArray = [expression matchesInString:textString options:0 range:NSMakeRange(0, [textString length])];

for (NSTextCheckingResult *result in textArray) {
    // set color for range
}


// Comments
expression = [NSRegularExpression regularExpressionWithPattern:@"(//[^\"\n]*)"
                                                options:0
                                                error:nil];

NSArray * arrayComments = [expression matchesInString:textString options:0 range:NSMakeRange(0, [textString length])];

for (NSTextCheckingResult *resultComment in arrayComments) {

    BOOL inside = NO;
    for (NSTextCheckingResult *resultText in textArray) {
        NSInteger from = resultText.range.location;
        NSInteger to = resultText.range.location+resultText.range.length;
        NSInteger now = resultComment.range.location;
        if (from < now && now < to) {
            inside = YES;
            break;
        }
    }
    if (!inside) {
        // set color for range
    }
}

Tags: , , , , , , , , , ,

Leave a Comment

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)

Loading ... Loading ...

 

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.

Tags: , , , , , , , , , ,

Leave a Comment

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)

Loading ... Loading ...

 

DDProgressView – Custom Progress View

DDProgressView is a custom progress view a la Twitter for iPhone.

DDProgressView works on both iOS and Mac OS. You must also compile the AppKitCompatibility.m file when targeting Mac OS.

Thanks, Damien DeVille!

Tags: , , , , ,

Leave a Comment

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)

Loading ... Loading ...

 

Page 1 of 1812345...10...Last »