您好我使用的是一个使用.position()。left()
的jQuery代码段这会找到元素左侧的位置。
有没有办法找到元素的中心?
我做了一些研究,没有.position()。center()
这样的东西所以我想做这样的事情
jQuery(this).position().center()
但这显然无效
任何人都对正确的语法有所了解吗?
谢谢!
答案 0 :(得分:1)
$(本).POSITION()。左()+ $(本)[0] .WIDTH / 2
您可以将jquery函数的左侧位置添加到元素宽度的一半。只需使用width属性
答案 1 :(得分:1)
您可以使用此
-(NSData *)copyImageAndChangeMetaData:(UIImage *)image {
NSData *imageData = UIImageJPEGRepresentation(image, 1.0);
CGImageSourceRef source = CGImageSourceCreateWithData((__bridge CFDataRef)imageData, NULL);
NSLog(@" source: 0x%x", source);
if (source == NULL) {
NSLog(@" source is NULL");
}
CFStringRef UTI = CGImageSourceGetType(source);
NSLog(@" UTI: %@", (__bridge NSString *)UTI);
if (UTI == NULL) {
NSLog(@" UTI is NULL");
}
NSMutableData *dest_data = [NSMutableData data];
CGImageDestinationRef destination = CGImageDestinationCreateWithData((__bridge CFMutableDataRef)dest_data, UTI, 1, NULL);
if (!destination)
{
NSLog(@"Image Data Error: Could not create image destination");
}
CFMutableDictionaryRef metadata = CFDictionaryCreateMutable(kCFAllocatorDefault, 2, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
int orient = 8;
CFNumberRef orientRef = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &orient);
CFDictionarySetValue(metadata, kCGImageDestinationOrientation, orientRef);
CFStringRef dateStringRef = CFStringCreateWithCString(kCFAllocatorDefault, "2017-06-06T17:31:46Z", kCFStringEncodingASCII);
CFDictionarySetValue(metadata, kCGImageDestinationDateTime, dateStringRef);
CFErrorRef errorRef = nil;
if (!CGImageDestinationCopyImageSource(destination, source, metadata, &errorRef)) {
CFStringRef error_description = CFErrorCopyDescription(errorRef);
NSString *errorDescription = (__bridge NSString *)error_description;
NSLog(@"Image Data Error: Error copying image data: %@", errorDescription);
CFRelease(error_description);
}
BOOL success = NO;
success = CGImageDestinationFinalize(destination);
if (!success)
{
NSLog(@"Image Data Error: Could not finalize image");
}
if (source != NULL) {
CFRelease(source);
}
if (destination != NULL) {
CFRelease(destination);
}
return dest_data;
}