1.: Introduce frame #import "Cllocation+gpsdictionary.h"
#import "Nsdictionary+cllocation.h" #import <assetslibrary/assetslibrary.h>2.-(void) Imagepickercontroller: ( uiimagepickercontroller*) Reader
Didfinishpickingmediawithinfo: (nsdictionary*) Info
{
NSString *strtype = [info objectforkey:uiimagepickercontrollermediatype];
if ([Strtype isequaltostring:@ "Public.image"])//When the selected type is a picture
{
__block nsmutabledictionary *imagemetadata = nil;
Nsurl *asseturl = [info objectforkey:uiimagepickercontrollerreferenceurl];
Alassetslibrary *library = [[Alassetslibrary alloc] init];
[Library Assetforurl:asseturl
resultblock:^ (Alasset *asset) {
Imagemetadata = [[Nsmutabledictionary alloc] initWithDictionary:asset.defaultRepresentation.metadata];
Console output view metadata of photos
Self.picdatainfo = imagemetadata[@ "{TIFF}"][@ "DateTime"];
NSLog (@ "%@**********", self.picdatainfo);
Self.editeornot = YES;
UIImage *image = [info objectforkey:@ "Uiimagepickercontrollereditedimage"]; Turn the picture into NSData first
Self.image = image;
[Reader Dismissviewcontrolleranimated:yes Completion:nil]; Close the album Screen
Self.imageview = [Crmfactory createimageviewwithframe:cgrectmake (SELF.TAKEPHOTOBUTTON.FRAME.ORIGIN.Y, 60, 60) Image:image];
[Self.view Addsubview:_imageview];
Look at the big picture
self.imageView.userInteractionEnabled = YES;
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initwithtarget:self action: @selector (Showpic)];
[Self.imageview Addgesturerecognizer:tap];
Self.takePhotoButton.frame = CGRectMake (60, 60);
UIImage *scaleimage = [Crmdatahandle scalefromimage:image];
UIImage *waterpoint = [self addtext:scaleimage text:self.picDataInfo];
NSData *data = uiimagejpegrepresentation (Waterpoint, 1.0);
Self.picname = [Crmdatahandle picname];
[Self uplosatoserversice:data];
}
failureblock:^ (Nserror *error) {
}];
}
}
#pragma mark-Add a watermark
-(UIImage *) AddText: (UIImage *) img Text: (NSString *) Mark {
if (mark.length! = 0) {
} else {
Convert timestamps to TIME
NSDate *date = [NSDate Date];
Qualifying formats
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[Formatter setdateformat:@ "Yyyy-mm-dd Hh:mm:ss"];
[Formatter Settimezone:[nstimezone timezonewithname:@ "GMT"];
Nstimezone *timezone = [Nstimezone timezonewithname:@ "China"];//time zone name or region name
[Formatter Settimezone:timezone];
Mark = [Formatter stringfromdate:date];
}
int w = img.size.width;
int h = img.size.height;
Uigraphicsbeginimagecontext (img.size);
[img drawinrect:cgrectmake (0, 0, W, h)];
Nsmutableparagraphstyle *paragraphstyle = [[Nsparagraphstyle Defaultparagraphstyle] mutableCopy];
Paragraphstyle.linebreakmode = nslinebreakbycharwrapping;
Nsdictionary *attribute = @{nsfontattributename: [Uifont systemfontofsize:25],
Nsparagraphstyleattributename:paragraphstyle,
Nsforegroundcolorattributename: [Uicolor Redcolor],
Nstexteffectattributename:nstexteffectletterpressstyle
};
[Mark Drawinrect:cgrectmake (0, H-40, W, max) Withattributes:attribute];
UIImage *aimage = Uigraphicsgetimagefromcurrentimagecontext ();
Uigraphicsendimagecontext ();
return aimage;}
Add a date watermark to an IOS selected photo or picture