             var croppedImage:CGImageRef = CGImageCreateWithImageInRect (im2.CGImage, newRect)
             UIImage(CGImage:croppedImage)!.drawInRect(CGRectMake(0,0,ceil(im1.size.width*percent),im1.size.height))
         }
+        
         var newImage = UIGraphicsGetImageFromCurrentImageContext()
-        
         UIGraphicsEndImageContext()
+        
         return newImage
     }
-    
+    /*generating image with color background*/
     func getBarImage(color:UIColor, textColor:UIColor)->UIImage{
         
         // Setup text parameters

            self.useImages = false
            self.updateImages()
        }
        self.backgroundImage.image = self.updateViewWithPercent(progressPercent,text: title as NSString)
        self.backgroundImage.clipsToBounds = true
        self.layer.masksToBounds = true
        }

    func updateViewWithPercent(percent:CGFloat, text:NSString) -> UIImage{
        
        return getmixedimages(percent, im1:self.completedImage ,im2:self.loadingImage)
    }
    
    func getmixedimages(percent:CGFloat,im1:UIImage,im2:UIImage)->UIImage{
        
        UIGraphicsBeginImageContext(im1.size)
        
        im1.drawInRect(CGRectMake(0,0,im1.size.width,im1.size.height))
        
        if(percent > 0 && percent <= 1.0){

        UIGraphicsEndImageContext()
        return coloredImg
    }
    /*generating image with custom background*/
    func getBarCustomImage(image:UIImage, textColor:UIColor)->UIImage{
        
        // Setup text parameters
