Affichage des articles dont le libellé est Active questions tagged ios - Stack Overflow. Afficher tous les articles
Affichage des articles dont le libellé est Active questions tagged ios - Stack Overflow. Afficher tous les articles

vendredi 8 mai 2015

iOS using UIGraphicsGetImageFromCurrentImageContext to detect certain pixels on screen

I have a UIView where the user can draw various UIBezierPaths.

I need to analyze the drawn BezierPaths to process certain patterns. I have not found any solution to converting UIBezierPaths to a list of coordinates/points, it seems like this is undoable? It's strange as this data must be stored and used someway to draw the actual paths..

So to bypass this problem i decided to draw the BezierPath with a width of 1px:

[path setLineWidth:1];

And convert my UIView to an UIImage:

UIGraphicsBeginImageContextWithOptions(self.bounds.size, NO, 0.0);
[self.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();

Then i can identify pixels by getting the color for a certain pixel position at the image:

- (UIColor *)colorAtPixel:(CGPoint)point {
    CGImageRef imageRef = [self CGImage];
    NSUInteger width = CGImageGetWidth(imageRef);
    NSUInteger height = CGImageGetHeight(imageRef);
    CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
    int bytesPerPixel = 4;
    long bytesPerRow = bytesPerPixel * width;
    int bitsPerComponent = 8;

    unsigned char *rawData = (unsigned char*) calloc(height * width * 4, sizeof(unsigned char));

    CGContextRef context = CGBitmapContextCreate(rawData,
                                                 width,
                                                 height,
                                                 bitsPerComponent,
                                                 bytesPerRow,
                                                 colorSpace,
                                                 kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big);

    CGColorSpaceRelease(colorSpace);
    CGContextDrawImage(context, CGRectMake(0, 0, width, height), imageRef);
    CGContextRelease(context);

    // Now your rawData contains the image data in the RGBA8888 pixel format.
    long byteIndex = (bytesPerRow * point.y) + point.x * bytesPerPixel;
    CGFloat red   = (rawData[byteIndex] * 1.0) / 255.0;
    CGFloat green = (rawData[byteIndex + 1] * 1.0) / 255.0 ;
    CGFloat blue  = (rawData[byteIndex + 2] * 1.0) / 255.0 ;
    CGFloat alpha = (rawData[byteIndex + 3] * 1.0) / 255.0;

    byteIndex += 4;
    UIColor *color = [UIColor colorWithRed:red green:green blue:blue alpha:alpha];
    free(rawData);

    return color;
}

Now my issue is that the image generated is blurry, if a draw a straight 1px BezierPath line and convert this to an UIImage, the line has a width of 3x because of it becomming blurry.

How can i solve this? Is there actually no possible way to convert BezierPaths to a list of coordinates?

Validate an input as JSON notation on iOS

I have an input field on an iOS app that accepts an NSString value. I want to be able to validate the input as a JSON object. For example:

NSString = @"{'foo':'bar'}" //would be validated as JSON notation
NSString = @"Hello world!" //would NOT be validated as JSON

I have tried using the following method:

[NSJSONSerialization isValidJSONObject:(id)obj]

However, it always returns false, even if the string input is something like {'hello':'world'}. Is there anything I'm doing wrong or missing here?

Comparing UI object in ios

I am making a super class to TableView, I will have static TextView in it and also I have TextView in cells.

Then I starting edit my TextView in Cell I assign it to static property of TableView.

Now I need go thought cells subviews, compare 2 textView (static and textView in cell) and find cell.

How can I compare 2 textViews?

I can not compare its texts because then some text did typed I lost event.

Django rotates iphone image after upload

I'm working on a photo website where I want the user to be able to upload a portrait or landscape oriented photo. The maximum width should be 1250px, but the maximum height could be 1667px if it's in portrait mode. When I upload photos in portrait orientation, they show up rotated 90 degrees to the left. Is there a way using Pillow to make sure the photo stays in the correct orientation?

This is my code:

class Result(models.Model):
    result01        = models.FileField(upload_to=get_upload_file_name, null=True, blank=True)
    result01thumb   = models.FileField(upload_to=get_upload_file_name, null=True, blank=True)

    def save(self):
        super(Result, self).save()
        if self.result01:
            size = 1667, 1250
            image = Image.open(self.result01)
            image.thumbnail(size, Image.ANTIALIAS)
            fh = storage.open(self.result01.name, "w")
            format = 'png'
            image.save(fh, format)
            fh.close()

It's important that users be able to upload photos from their phones while they're mobile, so the correct orientation is really important. Is there anything I can do here?

Apple Mach-O linker Error Xcode 6.2

i'm sorry if this question is repeated, but i only asked because i didn't find a solution in other related questions.

I started a new project in Xcode 6.2

Imported AFNetworking using pods.

Imported SWRevealViewController by dragging the two files (.h and .m) into the project.

Everything looks fine but when i build the project to test it gives me this insane error below.

I'm going crazy with this error.

Please see the image below:

Error Screenshot

Does anyone know how to deal with this?

Thanks in advance.

Setting Device Independent RGB on iOS

I am detecting the rgb of a tapped pixel. Different iPads return slightly different RGB values. I maintain a plist of the different values returned per device and when the app opens it determines the device I am on and uses appropriate values. This is a terrible solution - but it does work.

I now want to fix this properly so I dived into colorspace on iOS. It seems I can use CGColorSpaceCreateCalibratedRGB to set a standard RGB regardless of device so the values returned are the same? Or do I need to convert the

However, I do not know any of the values needed to create a standard color space across devices so my pixel color return values are always the same - or if this is possible.

Some current example return values: iPad 2 r31 g0 b133 a1 iPad Air r30 g0 b132 a1

Can anyone help 'normalize' the pixel return value in a device independent way?

- (UIColor*) getPixelColorAtLocation:(CGPoint)point {
UIColor* color = nil;
CGImageRef inImage = self.image.CGImage;
// Create off screen bitmap context to draw the image into. Format ARGB is 4 bytes for each pixel: Alpha, Red, Green, Blue
CGContextRef cgctx = [self createARGBBitmapContextFromImage:inImage];
if (cgctx == NULL) { return nil; /* error */ }

size_t w = CGImageGetWidth(inImage);
size_t h = CGImageGetHeight(inImage);
CGRect rect = {{0,0},{w,h}}; 

// Draw the image to the bitmap context. Once we draw, the memory 
// allocated for the context for rendering will then contain the 
// raw image data in the specified color space.
CGContextDrawImage(cgctx, rect, inImage); 

// Now we can get a pointer to the image data associated with the bitmap
// context.
unsigned char* data = CGBitmapContextGetData (cgctx);
if (data != NULL) {
    //offset locates the pixel in the data from x,y. 
    //4 for 4 bytes of data per pixel, w is width of one row of data.
    int offset = 4*((w*round(point.y))+round(point.x));
    int alpha =  data[offset]; 
    int red = data[offset+1]; 
    int green = data[offset+2]; 
    int blue = data[offset+3]; 
    ////NSLog(@"offset: %i colors: RGB A %i %i %i  %i",offset,red,green,blue,alpha);
    //NSLog(@"colors: RGB A %i %i %i  %i",red,green,blue,alpha);
    color = [UIColor colorWithRed:(red/255.0f) green:(green/255.0f) blue:(blue/255.0f) alpha:(alpha/255.0f)];
}


// When finished, release the context
CGContextRelease(cgctx); 
// Free image data memory for the context
if (data) { free(data); }

return color;

}

  • (CGContextRef) createARGBBitmapContextFromImage:(CGImageRef) inImage {

    CGContextRef context = NULL; CGColorSpaceRef colorSpace; void * bitmapData; int bitmapByteCount; int bitmapBytesPerRow;

    // Get image width, height. We'll use the entire image. size_t pixelsWide = CGImageGetWidth(inImage); size_t pixelsHigh = CGImageGetHeight(inImage);

    // Declare the number of bytes per row. Each pixel in the bitmap in this // example is represented by 4 bytes; 8 bits each of red, green, blue, and // alpha. bitmapBytesPerRow = (pixelsWide * 4); bitmapByteCount = (bitmapBytesPerRow * pixelsHigh);

    // Use the generic RGB color space. colorSpace = CGColorSpaceCreateDeviceRGB();

    if (colorSpace == NULL) { fprintf(stderr, "Error allocating color space\n"); return NULL; }

    // Allocate memory for image data. This is the destination in memory // where any drawing to the bitmap context will be rendered. bitmapData = malloc( bitmapByteCount ); if (bitmapData == NULL) { fprintf (stderr, "Memory not allocated!"); CGColorSpaceRelease( colorSpace ); return NULL; }

    // Create the bitmap context. We want pre-multiplied ARGB, 8-bits // per component. Regardless of what the source image format is // (CMYK, Grayscale, and so on) it will be converted over to the format // specified here by CGBitmapContextCreate. context = CGBitmapContextCreate (bitmapData, pixelsWide, pixelsHigh, 8, // bits per component bitmapBytesPerRow, colorSpace, kCGImageAlphaPremultipliedFirst); if (context == NULL) { free (bitmapData); fprintf (stderr, "Context not created!"); }

    // Make sure and release colorspace before returning CGColorSpaceRelease( colorSpace );

    return context; }

How to Recieve iOS Screen Lock Status

I am a noob just learning to code, so please bear with me.

I am trying to implement a location tracking application and here is my problem. I want to stop GPS updates when iPhone is locked or went into sleep mode.

I have used this discussion as reference point. This is what I have so far.

LockNotifierCallback.h

    #import <Foundation/Foundation.h>
@import CoreFoundation;

@interface LockNotifierCallback : NSObject

+ (void(*)(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo))notifierProc;

- (void)registerForDeviceLockNotifications;

@end

LockNotifierCallback.m

#import "LockNotifierCallback.h"
@import CoreFoundation;

static void lockcompleteChanged(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) {
    CFStringRef nameCFString = (CFStringRef)name;
    NSString *notificationName =  (__bridge NSString*)nameCFString;
    NSLog(@"Darwin notification NAME = %@",name);

    NSString *timerStatus = @"No Change";
    if ([notificationName isEqualToString:@"com.apple.springboard.lockcomplete"]) {
        timerStatus = @"Yes";
    } else if ([notificationName isEqualToString:@"com.apple.springboard.lockstate"]) {
       timerStatus = @"No";
    }

    NSLog(@"success");
}

@implementation LockNotifierCallback;

+ (void(*)(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo))notifierProc {
    return lockcompleteChanged;
}

- (void)registerForDeviceLockNotifications;
{
    NSLog(@"registering for device lock notifications");

    CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), //center
                                    NULL, // observer
                                    lockcompleteChanged, // callback
                                    CFSTR("com.apple.springboard.lockcomplete"), // event name
                                    NULL, // object
                                    CFNotificationSuspensionBehaviorDeliverImmediately);

    CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), //center
                                    NULL, // observer
                                    lockcompleteChanged, // callback
                                    CFSTR("com.apple.springboard.lockstate"), // event name
                                    NULL, // object
                                    CFNotificationSuspensionBehaviorDeliverImmediately);
}


@end

Xcode compiles this without any error but I don't think it is working as I don't see any logs in Console when I run the app in simulator.

Its a SWIFT project and I have #import "LockNotifierCallback.h" in my bridging header.

Please answer this in detail as I am still learning to code.

Appreciate your help.

EDIT

I am using Objective C only to receive Darwin notification for lockstate (device sleep / awake) to optimize battery life as my app will run in the background, apart from this I am planning to implement location tracking and other functions in SWIFT.

Convert NSString into NSArray in swift

I am getting following response as String:

({latitude="38.54708862304688";longitude="-75.11076354980469";statusColorName=blue;statusID=121;statusName="RespondingToStation";trackLocation=1;},{statusColorName=blue;statusID=2123;statusName="RespondingToScene";},{statusColorName=orange;statusID=185;statusName="AtStation";},{statusColorName=green;statusID=184;statusName=Available;},{statusColorName=red;statusID=183;statusName=Unavailable;})

How to convert it into Array in Swift ?

Scrolling a ViewController Swift

I am trying to make a view controller scrollable because there is not enough room on the screen at one time to fit everything. I have checked out links from Google on how to do this http://ift.tt/1Em0AJc and http://ift.tt/1RimFSU The only thing is that these examples use images while I on the other hand want to use buttons. How would I go about doing this? Thanks!

CGPDFStringGetBytePtr returning incorrect string while scanning pdf

I have one PDF and I am trying to scan PDF using CGPDFScanner. While scanning the pdf, when the word "file" is encountered, the CGPDFStringGetBytePtr API returns "\x02le". PDF is having Type1 font and no ToUnicodeMapping(CMap). Encoding dictionary is not present in the PDF hence using NSUTF8String encoding. However I have tried with all NSMacOSRomanStringEncoding, NSASCIIStringEncoding but had no luck. What can be the problem?

Thanks.

Invalid Signature - Code object is not signed at all. The binary at path [http://ift.tt/1dSpXwT] contains an invalid signature

Well, all was good with submitting to itunes connect, but out of the blue, I just got this email right after uploading my app:

Invalid Signature - Code object is not signed at all. The binary at path [http://ift.tt/1dSpXwT] contains an invalid signature. Make sure you have signed your application with a distribution certificate, not an ad hoc certificate or a development certificate. Verify that the code signing settings in Xcode are correct at the target level (which override any values at the project level). Additionally, make sure the bundle you are uploading was built using a Release target in Xcode, not a Simulator target. If you are certain your code signing settings are correct, choose "Clean All" in Xcode, delete the "build" directory in the Finder, and rebuild your release target.

I've seen that this a commun, infamous error message, and that there is no clear answer to how to fix this.

Here are a few screen shot of my setting:

My certificate: enter image description here

My target code signing settings: enter image description here

enter image description here

The provisioning profile used for submitting: enter image description here

Has anyone an idea on what could be wrong with my settings? Thanks you so much in advance, I'm suppose to release the app this month and I'm freaking out a little bit here...

JSON conversion issue in iOS

I have a json string and another one. i have to append together, send to server and get user id. I am stuck in d middle. Appended string is not getting converted to NSURL.


Here is my code.

- (void)convertingstringtojsondata
{
    NSArray *components = [[NSArray alloc]initWithObjects:ismunicipality,mobilenumberstring,placestring,namestring,  nil];
    NSArray *keys = [[NSArray alloc]initWithObjects:@"is_municipality",@"ph_nbr",@"place",@"reg_name", nil];
    NSLog(@"%@",components);

    NSDictionary *dict = [[NSDictionary alloc]initWithObjects:components forKeys:keys];

    NSLog(@"dict %@", dict);

    NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dict
                                                       options:0
                                                         error:nil];
    NSLog(@"JSON DATA %@", jsonData);

    jsonData= jsonData;

  JSONString = [[NSString alloc] initWithBytes:[jsonData bytes] length:[jsonData length] encoding:NSUTF8StringEncoding];

    NSLog(@"JSON STRING%@",JSONString);
}
-(void)sendjsonforregistration
{
 [self convertingstringtojsondata];

    registerwithserverstring = [[NSMutableString alloc]initWithString:@"http://ift.tt/1PtRVKM"];
    [registerwithserverstring appendString:JSONString];

    NSLog(@" appended string %@", registerwithserverstring);

    NSURL *registerURL = [NSURL URLWithString:registerwithserverstring];

    NSLog(@"register URL%@", registerURL);

NSMutableURLRequest * request = [[NSMutableURLRequest alloc]initWithURL:registerURL cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:0];
NSOperationQueue * queue = [[NSOperationQueue alloc]init];
[NSURLConnection sendAsynchronousRequest:request queue:queue completionHandler:^(NSURLResponse * response, NSData * data, NSError * error) {
    NSData * jsonData1 = [NSData dataWithContentsOfURL:registerURL];

    NSLog(@"%@", jsonData1);

    dataDictionary1 = [NSJSONSerialization JSONObjectWithData:jsonData1 options:0 error:&error];

   NSLog(@"DATA DICTIONARY %@", dataDictionary1);

}];
}


Problem:- The registerURL shows null value...

How to hide MPMediaItemPropertyPlaybackDuration slider from locked screen and Control Center?

I'm working on online radio player and need some help. When I set MPNowPlayingInfoCenter.defaultCenter().nowPlayingInfo I have title, controls and playback duration slider. I don't need this slider because I have no info about playback duration and moreover it is not a very good looking control. Can somebody prompt me how to hide playback duration slider? And one more question: since the app is online radio player, the user have no ability to forward or rewind the playback, so I want to hide this controls from locked screen and Control Center either. By the way I'm using Swift. Thanks in advance!

best framework for mobile game development

I have made few games in pygame for windows but i want to develop games for android and ios how would pygame be used for that or is there a better way?

Double quotes not showing up in string value inside NSMutableDictionary [duplicate]

I'm trying to post some json content to server using REST apis. On POST request, server is accepting the content value like the one given below in body

{
    "value" = "MyDataValue";
}

But after creating the web request, when I try to log the POST data, what I'm getting in console output is

{
    "value" = MyDataValue;
}

Note: No double quotes around MyDataValue.

On trying the same request with double quotes on chrome poster returns success and without double quotes returns same error in poster also. So I guess adding double quotes would solve the issue.

Here is the code I used for creating the NSDictionary

NSMutableDictionary *parameterDict = [NSMutableDictionary new];  
[parameterDict setObject:@"MyDataValue"forKey:@"value"];

Also, tried adding double quotes using escape character, but returns in 2 double quotes which also returns error. So any other alternative solution would be helpful.

Thanks.

iOS - api to route to a specific location using public transport

I'd like to know if there is an api , which I could use to route to a specific location combined with information belonging to public transport such as departure times or travel times (between train stations).

I read something about Google Transit. But can I use this api for IOS apps? Are there any other (free) api's?

Best regards, Nazar Medeiros

Cropping AVCaptureVideoPreviewLayer output to a square

I am having issues with my AVCaptureVideoPreviewLayer method when grabbing a cropped UIImage of the viewable screen. Currently it is working but not outputting the correct crop that I require.

I am trying to output a square but it (by the looks of it) seems to be giving the full height and compressing the image.

The before image shows the LIVE screen and the after image shows the image once the capture button has been pressed. You can see that it has been changed vertically to fit the square but the height hasn't been cropped vertically.

enter image description here

Capture Image Code

[stillImageOutput captureStillImageAsynchronouslyFromConnection:videoConnection completionHandler: ^(CMSampleBufferRef imageSampleBuffer, NSError *error) {

    if (imageSampleBuffer != NULL) {

        NSData *imageData = [AVCaptureStillImageOutput jpegStillImageNSDataRepresentation:imageSampleBuffer];
        [self processImage:[UIImage imageWithData:imageData]];

    }
}];

Cropping code

- (void) processImage:(UIImage *)image { //process captured image, crop, resize and rotate

        haveImage = YES;

    CGRect deviceScreen = _previewLayer.bounds;
    CGFloat width = deviceScreen.size.width;
    CGFloat height = deviceScreen.size.height;

    NSLog(@"WIDTH %f", width); // Outputing 320
    NSLog(@"HEIGHT %f", height); // Outputting 320

    UIGraphicsBeginImageContext(CGSizeMake(width, width));
    [image drawInRect: CGRectMake(0, 0, width, width)];

    UIImage *smallImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

    CGRect cropRect = CGRectMake(0, 0, width, width);

    CGImageRef imageRef = CGImageCreateWithImageInRect([smallImage CGImage], cropRect);

    CGImageRelease(imageRef);

    [captureImageGrab setImage:[UIImage imageWithCGImage:imageRef]];

}

Adobe Creative SDK API Key Error

I have configured adobe image SDK in my IOS APP and i have also pass API KEY and Secret Key but while i call edit image am getting Invalid API or Secret Key error here is my code how am passing API KEY and Secret Key

Error:
Invalid API Key and Secret
Please check to make sure you have correctly entered your API key and secret.

Code:

static dispatch_once_t onceToken;

dispatch_once(&onceToken, ^{

    [[AdobeUXAuthManager sharedManager] setAuthenticationParametersWithClientID:@"5587f31263dc4f38b003dc0a5d9a2e5f" withClientSecret:@"81292c83-eec7-42df-be72-334cbc1d6828"];

});

If a user modifies a value, change it in real time on all the apps

This is just a question regarding the concept so I'm not looking on code snippets or something similar because I'm not a programmer but rather...let's say the product owner so I need to know what it takes to achieve this before talking with the developers (which I need to find first).

So here it is: I am thinking on creating an app compatible both with iOS and Android which (amongst other things) will display a value with the following characteristics:

  1. This value will be visible to all the users that are running the app
  2. If a user clicks on a particular button, the value is incremented.
  3. If the value is incremented, all other users will see the new value in real time.
  4. The value can be changed thousands of time per second, deepening on how many users are clicking the button.

Again, I'm mainly interested in the concept so any suggestion will be appreciated. For example since the value will get updated so many times per second, how do I store/modify it? Or how can I push it so fast to all the apps?

Trying to Set Photo As A Mandatory Field during Signup with Pare

I am still new to coding. I have setup my signup screen but I wanted to make it mandatory to upload a profile picture during signup. I've tried to add and "if statement" to show an alert if the photo isn't uploaded but I haven't been successful getting it to work. Any suggestions? Here is my code:

class SignUpViewController: UIViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate {

@IBOutlet var usernameField: UITextField!

@IBOutlet var activityIndicator: UIActivityIndicatorView!
@IBOutlet var message: UILabel!
@IBOutlet var emailField: UITextField!
@IBOutlet var passwordField: UITextField!
@IBOutlet var firstNameField: UITextField!
@IBOutlet var lastNameField: UITextField!

@IBOutlet var profilePic: UIImageView!




@IBAction func submitDataAction(sender: AnyObject) {


    var userName = usernameField.text
    var userEmail = emailField.text
    var userPassword = passwordField.text
    var firstName = firstNameField.text
    var lastName = lastNameField.text
    var initialImage = UIImage(named: "DidNotLoad")
    var picfile = profilePic.image
    let imageData = UIImagePNGRepresentation(picfile)
    let imageFile = PFFile(data: imageData)







    userEmail = userEmail.lowercaseString

    // Start activity indicator
    activityIndicator.hidden = false
    activityIndicator.startAnimating()

    var newUser = PFUser()
    newUser.username = userName.lowercaseString
    newUser.password = userPassword
    newUser.email = userEmail
    newUser["FirstName"] = firstName
    newUser["LastName"] = lastName
    newUser["ProfilePic"] = imageFile



    newUser.signUpInBackgroundWithBlock {(succeeded: Bool, error: NSError?) -> Void in
        if error == nil {
            dispatch_async(dispatch_get_main_queue()) {
                self.performSegueWithIdentifier("PushToEventsTableFromSignUp", sender: self)
            }

            self.activityIndicator.stopAnimating()
        }
        else {
            if let message: AnyObject = error!.userInfo!["error"] {
                self.message.text = "\(message)"

            }
        }
    }
}

@IBAction func uploadPhoto(sender: AnyObject) {
    //Create variable for image controller
    var picPhoto = UIImagePickerController()
    picPhoto.delegate = self
    picPhoto.sourceType = UIImagePickerControllerSourceType.PhotoLibrary
    picPhoto.allowsEditing = true
    self.presentViewController(picPhoto, animated: true, completion: nil)

}
func imagePickerController(picker: UIImagePickerController, didFinishPickingImage image: UIImage!, editingInfo: [NSObject : AnyObject]!) {

   self.dismissViewControllerAnimated(true, completion: { () -> Void in

    })

    profilePic.image = image
}


override func viewDidLoad() {
    super.viewDidLoad()
    self.makingRoundedImageProfileWithRoundedBorder()
    activityIndicator.hidden = true
    activityIndicator.hidesWhenStopped = true


    // Do any additional setup after loading the view.
}


private func makingRoundedImageProfileWithRoundedBorder() {
    self.profilePic.layer.cornerRadius = self.profilePic.bounds.size.width/2;
    self.profilePic.layer.masksToBounds = true
   // self.profilePic.clipsToBounds = true

    //Create Border around profile Pic
    self.profilePic.layer.borderWidth = 2.0
    self.profilePic.layer.borderColor = UIColor.whiteColor().CGColor
}