How can I tint a UIImage with gradient?

EDIT: Here is a version which supports non-retina and retina displays The method can be used as a category for UIImage + (UIImage *)imageWithGradient:(UIImage *)img startColor:(UIColor *)color1 endColor:(UIColor *)color2 { UIGraphicsBeginImageContextWithOptions(img.size, NO, img.scale); CGContextRef context = UIGraphicsGetCurrentContext(); CGContextTranslateCTM(context, 0, img.size.height); CGContextScaleCTM(context, 1.0, -1.0); CGContextSetBlendMode(context, kCGBlendModeNormal); CGRect rect = CGRectMake(0, 0, img.size.width, img.size.height); //CGContextDrawImage(context, rect, img.CGImage); … Read more

DrawableCompat tinting does not work on pre-Lollipop

When you call wrap() then the original Drawable is wrapped internally into a new DrawableWrapper which is used to implement the tinting on older devices. So to make it work you have to set the returned Drawable back to the EditText: final Drawable originalDrawable = editText.getBackground(); final Drawable wrappedDrawable = DrawableCompat.wrap(originalDrawable); DrawableCompat.setTintList(wrappedDrawable, ColorStateList.valueOf(Color.RED)); editText.setBackground(wrappedDrawable); Since … Read more

Android: Tint using DrawableCompat

In case anyone needs to use DrawableCompat‘s tinting without affecting other drawables, here’s how you do it with mutate(): Drawable drawable = getResources().getDrawable(R.drawable.some_drawable); Drawable wrappedDrawable = DrawableCompat.wrap(drawable); wrappedDrawable = wrappedDrawable.mutate(); DrawableCompat.setTint(wrappedDrawable, getResources().getColor(R.color.white)); Which can be simplified to: Drawable drawable = getResources().getDrawable(R.drawable.some_drawable); drawable = DrawableCompat.wrap(drawable); DrawableCompat.setTint(drawable.mutate(), getResources().getColor(R.color.white));

How can I tint a background image with CSS?

Use background-blend-mode for a simple tint You can use the background-blend-mode css property: .box { width: 300px; height: 300px; background-size: cover; background-image: url(‘https://placehold.co/300′); } .background-tint { background-color: rgba(200,100,0,.5); background-blend-mode: multiply; } <div class=”box background-tint”></div> Place it on any element with a background image and you’re good to go. The property is well supported in modern … Read more

How would I tint an image programmatically on iOS?

In iOS7, they’ve introduced tintColor property on UIImageView and renderingMode on UIImage. To tint an UIImage on iOS7, all you have to do is: UIImageView* imageView = … UIImage* originalImage = … UIImage* imageForRendering = [originalImage imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; imageView.image = imageForRendering; imageView.tintColor = [UIColor redColor]; // or any color you want to tint it with

Lollipop’s backgroundTint has no effect on a Button

The bad news Like BoD says, it’s meaningless to tint a Button’s background in Lollipop 5.0 (API level 21). The good news Lollipop 5.1 (API level 22) seems to have fixed this by changing btn_mtrl_default_shape.xml (among other files): https://android.googlesource.com/platform/frameworks/base/+/6dfa60f33ca6018959ebff1efde82db7d2aed1e3%5E!/#F0 The great news The new support library (version 22.1+) adds backward-compatible tinting support to lots of … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)