Skip to content

Instantly share code, notes, and snippets.

View tediscript's full-sized avatar
🎯
Focusing

Alfredo Pareto tediscript

🎯
Focusing
View GitHub Profile
private void doExit() {
AlertDialog.Builder ab = new AlertDialog.Builder(MainActivity.this);
ab.setMessage("Are you sure you want to exit?")
.setPositiveButton("Yes", dialogClickListener)
.setNegativeButton("No", dialogClickListener).show();
}
private DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
- (UIImage *)imageWithImage:(UIImage *)image scaledToSize:(CGSize)newSize {
//UIGraphicsBeginImageContext(newSize);
UIGraphicsBeginImageContextWithOptions(newSize, NO, 0.0);
[image drawInRect:CGRectMake(0, 0, newSize.width, newSize.height)];
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return newImage;
}
- (UIImage*) drawText:(NSString*)text inImage:(UIImage*)bgImage atPoint:(CGPoint)point withSize:(CGFloat)size withColor:(UIColor*) color {
UIGraphicsBeginImageContextWithOptions(bgImage.size, FALSE, 0.0);
[bgImage drawInRect:CGRectMake( 0, 0, bgImage.size.width, bgImage.size.height)];
UIFont *font = [UIFont boldSystemFontOfSize:size];
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(ctx, color.CGColor);
[text drawAtPoint:point withFont:font];
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
[UIFont boldSystemFontOfSize:17.0];
- (UIImage*) drawImage:(UIImage*) fgImage inImage:(UIImage*) bgImage atPoint:(CGPoint) point {
UIGraphicsBeginImageContextWithOptions(bgImage.size, FALSE, 0.0);
[bgImage drawInRect:CGRectMake( 0, 0, bgImage.size.width, bgImage.size.height)];
[fgImage drawInRect:CGRectMake( point.x, point.y, fgImage.size.width, fgImage.size.height)];
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return newImage;
}
NSString *url = @"http://www.developerfeed.com/search.jsp?params=Java Developer";
NSString* encodedUrl = [url stringByAddingPercentEscapesUsingEncoding: NSASCIIStringEncoding];
NSLog(@"Encoded URL %@",encodedUrl);
// output will be
//http://www.developerfeed.com/search.jsp?params=Java%20Developer;
NSString *string1 = @"This is";
NSString *string2 = @" a test.";
NSString *string3 = [string1 stringByAppendingString:string2];
// string3 is now @"This is a test." string1 and string2 are unchanged.
//You can also assign the new string back to string1:
NSString *string1 = @"This is";
NSString *string2 = @" a test.";
string1 = [string1 stringByAppendingString:string2];
button.titleLabel.textAlignment = NSTextAlignmentCenter;
NSArray *items = [dataDictionary objectForKey:@"items"];
[self.tableView reloadData];