This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@interface UILabelStrikethrough : UILabel { | |
int xOffset; | |
int yOffset; | |
int widthOffset; | |
int stroke; | |
UIColor* strokeColor; | |
} | |
@property (nonatomic) int xOffset; | |
@property (nonatomic) int yOffset; | |
@property (nonatomic) int widthOffset; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
最近的工作是进行程序由 SUN SPARC 向 Intel X86 移植的工作,多数问题都出现在网络字节序的部分,所以拿出来在这部分工作中使用频率较高的几个接口区分比较下:) | |
ntohs =net to host short int 16位 | |
htons=host to net short int 16位 | |
ntohl =net to host long int 32位 | |
htonl=host to net long int 32位 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
typedef struct bitS | |
{ | |
unsigned bit0:1; | |
unsigned bit1:1; | |
unsigned bit2:1; | |
unsigned bit3:1; | |
unsigned bit4:1; | |
unsigned bit5:1; | |
unsigned bit6:1; | |
unsigned bit7:1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(BOOL) textFieldShouldBeginEditing:(UITextField *)textField{ | |
[textField setBackground:[UIImage imageNamed:@"ctext_field_02.png"]]; | |
return YES; | |
} | |
-(void) textFieldDidEndEditing:(UITextField *)textField{ | |
[textField setBackground:[UIImage imageNamed:@"ctext_field_01.png"]]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// UIView+JTRemoveAnimated.h | |
// | |
// Created by james on 9/1/11. | |
// http://ioscodesnippet.tumblr.com/ | |
// | |
@interface UIView (JTRemoveAnimated) | |
- (void)removeFromSuperviewAnimated; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)makeCall:(NSString *)number | |
{ | |
NSString *txt = number; | |
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"[0-9]{4}[-]{0,1}[0-9]{4}?" options:NSRegularExpressionSearch error:nil]; | |
NSTextCheckingResult *result = [regex firstMatchInString:txt options:0 range:NSMakeRange(0, [txt length])]; | |
NSString *cleanedString = [[[txt substringWithRange:[result range]] componentsSeparatedByCharactersInSet:[[NSCharacterSet characterSetWithCharactersInString:@"0123456789-+()"] invertedSet]] componentsJoinedByString:@""]; | |
NSString *escapedPhoneNumber = [cleanedString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; | |
NSURL *telURL = [NSURL URLWithString:[NSString stringWithFormat:@"tel://%@", escapedPhoneNumber]]; | |
[[UIApplication sharedApplication] openURL:telURL]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+ (UIImage *) imageFromURLString: (NSString *) urlstring | |
{ | |
// This call is synchronous and blocking | |
return [UIImage imageWithData:[NSData | |
dataWithContentsOfURL:[NSURL URLWithString:urlstring]]]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+ (UIImage *) grayscaleImage: (UIImage *) image | |
{ | |
CGSize size = image.size; | |
CGRect rect = CGRectMake(0.0f, 0.0f, image.size.width, | |
image.size.height); | |
// Create a mono/gray color space | |
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceGray(); | |
CGContextRef context = CGBitmapContextCreate(nil, size.width, | |
size.height, 8, 0, colorSpace, kCGImageAlphaNone); | |
CGColorSpaceRelease(colorSpace); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UIBarButtonItem *barButtonItem = [[UIBarButtonItem alloc] init]; | |
barButtonItem.title = @"buttonName"; | |
self.navigationItem.backBarButtonItem = barButtonItem; | |
[barButtonItem release] |
NewerOlder