Skyla  Feeney

Skyla Feeney

1595425440

Background with rounded corners in UITextView

I have had the opportunity to learn so many things while working on Proton. Just as much as I like sharing my code, I also enjoy talking about the challenges and the wins. This article focuses on yet another feature in Proton which, I believe, should have been available out of the box in iOS. If you are new here and before diving into the details, would like to know more about ProtonBuilding a native editor for iOS is a good place to start.

Text with background

Often there are times when we want to add background to the text in a text view. The most simplest, and probably best, approach is to use backgroundColor attribute. You can provide any UIColor to a given range, and iOS takes care of rendering that color in the background of the text.

Image for post

Text with .backgroundColor attribute

The only code you need is to add attribute backgroundColor: UIColor.cyan to the list of NSAttributedString.Key in the attributedText property of UITextView. While this works for most cases, it may feel too vanilla. You might want a fancier formatting like adding shadows or borders. At the very least, it is very likely that you would want rounded corners to the background. Unfortunately, none of these properties may be modified by just using attributes.

#uitextview #ios #swift #background

What is GEEK

Buddha Community

Background with rounded corners in UITextView
Skyla  Feeney

Skyla Feeney

1595425440

Background with rounded corners in UITextView

I have had the opportunity to learn so many things while working on Proton. Just as much as I like sharing my code, I also enjoy talking about the challenges and the wins. This article focuses on yet another feature in Proton which, I believe, should have been available out of the box in iOS. If you are new here and before diving into the details, would like to know more about ProtonBuilding a native editor for iOS is a good place to start.

Text with background

Often there are times when we want to add background to the text in a text view. The most simplest, and probably best, approach is to use backgroundColor attribute. You can provide any UIColor to a given range, and iOS takes care of rendering that color in the background of the text.

Image for post

Text with .backgroundColor attribute

The only code you need is to add attribute backgroundColor: UIColor.cyan to the list of NSAttributedString.Key in the attributedText property of UITextView. While this works for most cases, it may feel too vanilla. You might want a fancier formatting like adding shadows or borders. At the very least, it is very likely that you would want rounded corners to the background. Unfortunately, none of these properties may be modified by just using attributes.

#uitextview #ios #swift #background

How to Fake Opacity With a CSS Background

I came across an interesting bit while working on the hero section of my z-index guide. I needed a way to apply an opacity for the background.

Here is the final result I want to achieve…

At the first glance, it might be tempting to say that it’s easy. However, it’s a bit more detailed. Let’s dig into the details of it.

The Layers

  • Solid background
  • Pattern image
  • Oval blurred shape: to make it easier to read the text content.

For me, 3D is a good way to imagine how to stack the layers. I also made a video to make it more clear.

If you’re not into 3D, it’s totally fine. Here is a normal view of all the layers.

The Requirements

  • I need a dynamic way to fake an opacity for the pattern image.
  • I shouldn’t use an additional HTML element for this job.
  • It should be responsive.

To implement that, we can use multiple CSS gradients. Here is how I did it:

:root {
  --oval-w: 50%;
  --oval-h: 70%;
  --base-color: rgba(194, 236, 231, 0.8);
  --pattern: url("hero-bg.svg");
}

.hero {
  min-height: 400px;
  background: linear-gradient(var(--base-color), var(--base-color)),
    radial-gradient(#c2ece7 25%, transparent) center/50% 90% no-repeat, var(
        --pattern
      ) center/cover no-repeat;
}

Code Explanation

  • What comes later in the gradient is displayed the last (The opposite of the stacking order).
  • In CSS gradients, using the same value for a linear gradient will result in a solid color. I like using this method. The solid color with rgba() will fake the opacity for us.
  • The oval shape is created with a radial gradient.
  • I used percentages for the oval shape, so it can resize based on the screen size.

With that, I used the pattern image as it is without altering its opacity manually. I can change the background color the way I want without using a design program in case I changed the pattern.

#snippet #css background #css #background

CSS background image tutorial with examples

This article was originally published at: https://www.blog.duomly.com/css-background-image-tutorial-with-examples/


The background image is probably one of the CSS properties which all of us, front-end developers, used at least a few times in our careers. Most people think that there can’t be anything unusual about background-image, but after a quick research, I have a different conclusion.

There are lots of questions askes about CSS background image every day in Facebook groups and lots of unknown tricks which can help us to achieve amazing effects and make stunning apps and websites.

That’s the reason I decided to create this article to show you what magic can be done using such a simple CSS property. I gathered seven tips and tricks I believe will be the most useful and create some code examples where you can check what’s going on there for you.

And, if as usually if you don’t like reading, jump to our Youtube channel for a video version.

Let’s check what’s behind the background!

1. How to fit a background image perfectly to a viewport?

Let’s start from something that’s more tip than a trick. How often it happened to you that you had to struggle with your background image to make in perfectly fitted and not stretched and unattractive?

Let me show you the way how to make your background image always perfectly fitted to your browser window!

2. How to use multiple background images with CSS?

Hm, and what if I’d like to add more then one image in the background?

That’s possible and not very difficult, but can give a nice result while you’ve got an idea to mix two graphics into something beautiful.

I personally think that it’s super useful when we want to add a pattern on the top of a background image, so that’s what I will show you in this example.

Let’s see how it works!

3. How to create a triangular background image?

Another exciting CSS background image trick is a triangular background image. It creates a really beautiful effect, especially when we would like to show some totally different options like day and night, or winter and summer.

It is done by creating two divs, both for the full viewport, then it’s needed to add a background image to both of them, and next, the second div needs a clip-path property to create a triangle shape.

Let’s see the code and result!

4. How to add a gradient overlay to my background image?

The fourth trick I’d like to show you in this article is about overlay on the background image. It can be useful when you would like to put some text on the image, but it’s too light, and text is not visible, but it can also improve the image itself.

For example, sunset images can be strengthened by adding a pink-orange gradient or red to transparent gradient.

Let’s see how we can easily add a gradient overlay to the background image!

5. How to create a color-changing background image animation?

And what if you can decide which color is the best as an overlay for your background image? Then animations on background images are really useful.

Using an animated overlay can give your website a great final effect, and for sure, people will remember it.

Let’s see what we can do using background images and animations in CSS!

6. How to make a grid background image?

Sometimes it’s a great idea to go a little bit more crazy, especially if the project is about art or photography, then a nice background image can be created with CSS grid and CSS background image.

Oh, if you don't know what's CSS grid check it out here.

Let’s take a look!

7. How to set a background image as a text color?

Using background image with background-clip you can achieve a beautiful effect of the background image for text. In some cases, it may be very useful, especially when you’d like to create a big text header, but not as boring as a normal color.

Let’s see the stunning effect we can get!

Conclusion

In this article, you could see 7 different tips and tricks to make amazing things with the background image. I’m pretty sure those hints will be helpful and allow you to get amazing results on your layouts. If you’d like to check out some more interesting CSS tips and tricks, check out our latest CSS borders tips and tricks article and one of the previous CSS tips and tricks.

If you have ever used any customized solution for your background let me know in the comments, I will be happy to find out what more can be done with CSS background image property.

Thank you for reading,

Anna from Duomly

#css #background #background-image #html #coding

Trace  Hoeger

Trace Hoeger

1624514880

Background Jobs in Heroku with Azure Service Bus

Web applications are optimized for throughput and latency to service a high number of HTTP requests as quickly as possible. For improved performance, web applications defer the CPU intensive, IO intensive, time-intensive, and scheduled processing workloads to background jobs that run independently of the user interface. These background jobs must function without intervention from the user interface and should not block a synchronous user and system interaction. Offloading slow and compute or memory-intensive activity to background jobs improves web applications’ performance and throughput.

For example, consider an eCommerce web application that captures a customer’s orders and triggers the background jobs to process the orders further. The application’s background jobs work with the operational data (all orders placed by customers) and the contextual data (orders for a single customer) to update the inventory and shipping systems.

Heroku supports several queue services as add-ons such as RabbitMQKafka, and IronMQ. However, you are not limited to using add-ons for integrating with cloud queue services. In this example, we will build a background job that processes messages from an Azure Service Bus queue. AWS, Azure, and GCP offer message queues as a service that you can use to extend the capabilities of your Heroku applications.

Azure Service Bus offers a rich set of features including support for At-Least-Once and At-Most-Once delivery guarantee. Azure Service Bus also offers First In, First Out (FIFO) messages for both point-to-point (queue) and publish/subscribe communication. While Heroku’s application platform is simple, easy to scale, and supports low ceremony DevOps integration, Azure supports an array of enterprise grade services of Azure that can be easily integrated. For complex scenarios, you will find it easy to build applications by integrating the right services across the cloud.

Background Jobs in Heroku

Heroku allows you to compose your application from various process types such as web and worker processes. In this demo, we will deploy a simple background worker process that processes messages from a work queue. Heroku allows you to scale the processes in an application independently, which gives you the ability to scale worker instances in proportion to the workload.

Apart from the worker, a feature-rich queue is the next crucial component of an event-driven worker process. Azure Service Bus queue service allows consumer processes to lock and process messages independently, enabling you to scale the number of worker dynos and achieve high throughput. Let’s discuss the Azure Service Bus queue service in detail next.

#azure service bus #heroku #background #background jobs

Shawn  Durgan

Shawn Durgan

1597850100

Swift iOS BackgroundTasks framework — Background App Refresh in 4 Steps

IOS allows app to refresh it content even when it is sent to background. iOS can intelligently study the user’s behaviour and schedule background tasks to the moment right before routine usage. It is useful for app to retrieve the latest information from its server and display to user right when app is resumed to foreground. Examples are social media app (Facebook, Instagram & WhatsApp) and news app.

Image for post

illustration of foreground and background task; Copy from WWDC 2019 presentation slide

Since iOS 13, Apple has added a new framework — BackgroundTasks — to handle the background task request between iOS and app side. BGAppRefreshTask & BGProcessingTask are the two available types of background task. BGAppRefreshTask can have 30 seconds to complete its job and BGProcessingTask can have more than a minute. The handling method is different for the old application(_:performFetchWithCompletionHandler:) way.

Background task execution depends on several conditions, including:

  1. User permission on “Background App Refresh”
  2. Power supply from charger
  3. Network connectivity

Let’s see how to setup the Background App Refresh and understand the details on using it!


4 Steps to Background App Refresh

Step 1) Enable Background Modes for app target

Go to the “Background Modes” session of the app target and check “Background fetch” and “Background processing” options if BGAppRefreshTask and BGProcessingTask are used respectively.

Image for post

#ios-app-development #background-task #swift #background #ios