Skip to content

Instantly share code, notes, and snippets.

View lappp9's full-sized avatar

Luke Parham lappp9

View GitHub Profile
let shadow = NSShadow()
shadow.shadowColor = UIColor = UIColor.black.withAlphaComponent(0.3)
shadow.shadowOffset = CGSize(width: 2.0, height: 2.0)
shadow.shadowBlurRadius = 5.0
let attributes = [NSAttributedStringKey.shadow: shadow]
label.attributedText = NSAttributedString(string: "Text with shadow", attributes: attributes)
view.layer.shadowOffset = CGSize(width: 5.0, height: 5.0)
view.layer.shadowColor = UIColor.black.cgColor
view.layer.shadowRadius = 5.0
view.layer.shadowOpacity = 0.5
view.layer.shadowPath = UIBezierPath(rect: view.bounds).cgPath
int *array = (int *)calloc(1, sizeof(int) * 2);
printf("The initial arrays location is %p\n", array);
array[1] = 777;
int size = sizeof(array)/sizeof(array[0]);
for(int i = 0; i < size; i++) {
printf("%d ", array[i]); // show the array
}
printf("\n");
layer.shadowPath = CGPathCreateWithRect(layer.bounds, NULL);
CALayer *layer = [[CALayer alloc] init];
layer.shadowColor = [UIColor purpleColor].CGColor;
layer.shadowOpacity = 0.5;
layer.shadowRadius = 5.0;
layer.shadowOffset = CGSizeMake(1.0, 1.0);
NSString *filename = [[NSBundle mainBundle] pathForResource:@“fileName.png” ofType:nil];
if (filename) {
[UIImage imageWithContentsOfFile:filename];
}
@lappp9
lappp9 / multiplex.mm
Last active May 30, 2016 18:31
MutliplexImageNode Example
- (instancetype)initWithURLs:(NSDictionary *)urls
{
_imageUrls = urls; // something like @{@"thumb": "/smallImageUrl", @"/medium": ...}
_multiplexImageNode = [[ASMultiplexImageNode alloc] initWithCache:nil downloader:[[ASBasicImageDownloader alloc] init]];
_multiplexImageNode.downloadsIntermediateImages = YES;
_multiplexImageNode.imageIdentifiers = @[ @"original", @"medium", @"thumb" ];
}
@lappp9
lappp9 / nodes.mm
Created February 27, 2016 22:59
Async Example
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
_imageNode = [[ASNetworkImageNode alloc] init];
_imageNode.defaultImage = [UIImage imageNamed:@"lightGrayPlaceholder"];
_imageNode.frame = CGRectMake(0, 0, _screenWidth - 2, _screenHeight * (5.0/12.0));
_imageNode.cornerRadius = 2;
_imageNode.delegate = self;
dispatch_async(dispatch_get_main_queue(), ^{
[self.view addSubview:_imageNode.view];
});
:convert_options => {
:medium => "-quality 80 -interlace Plane",
:thumb => "-quality 80 -interlace Plane"
}
:convert_options => { thumb: "-interlace Plane" }