Telegram Group & Telegram Channel
Как iOS 18 улучшает работу с градиентами

Очень часто в проектах разработчики используют дополнительный градиент, чтобы создать контраст между фоном и текстом.
*Или используют заранее заготовленный ассет в каталоге ресурсов.

Однако при таком использовании линейного градиента будут видны перепады яркости и резкий переход.

📖 В iOS 18 доступно новое API для смешивания цветов. Поэтому, используя UnitCurve, можно интерполировать цвета с помощью встроенных или кастомных кривых Безье, чтобы обеспечить плавность перехода.

Пример использования под катом (разверните, чтобы посмотреть):
extension Gradient {
init(from: Color, to:Color, with curve:UnitCurve, steps:Int = 10) {
let colors = stride(from: 0.0, through: 1.0, by: 1.0 / Double(steps))
.map { f in
from.mix(with: to, by: curve.value(at: f))
}
self.init(colors: colors)
}
}


📖 Почитать дополнительно про смешивание цветов можно в этой статье.

😃 iOS Devбольше разборов тут
Please open Telegram to view this post
VIEW IN TELEGRAM
22👍5🔥4❤‍🔥21👏1💯1🏆1🤗1🎄1



tg-me.com/iosdev/1299
Create:
Last Update:

Как iOS 18 улучшает работу с градиентами

Очень часто в проектах разработчики используют дополнительный градиент, чтобы создать контраст между фоном и текстом.
*Или используют заранее заготовленный ассет в каталоге ресурсов.

Однако при таком использовании линейного градиента будут видны перепады яркости и резкий переход.

📖 В iOS 18 доступно новое API для смешивания цветов. Поэтому, используя UnitCurve, можно интерполировать цвета с помощью встроенных или кастомных кривых Безье, чтобы обеспечить плавность перехода.

Пример использования под катом (разверните, чтобы посмотреть):

extension Gradient {
init(from: Color, to:Color, with curve:UnitCurve, steps:Int = 10) {
let colors = stride(from: 0.0, through: 1.0, by: 1.0 / Double(steps))
.map { f in
from.mix(with: to, by: curve.value(at: f))
}
self.init(colors: colors)
}
}


📖 Почитать дополнительно про смешивание цветов можно в этой статье.

😃 iOS Devбольше разборов тут

BY iOS Dev




Share with your friend now:
tg-me.com/iosdev/1299

View MORE
Open in Telegram


telegram Telegram | DID YOU KNOW?

Date: |

The STAR Market, as is implied by the name, is heavily geared toward smaller innovative tech companies, in particular those engaged in strategically important fields, such as biopharmaceuticals, 5G technology, semiconductors, and new energy. The STAR Market currently has 340 listed securities. The STAR Market is seen as important for China’s high-tech and emerging industries, providing a space for smaller companies to raise capital in China. This is especially significant for technology companies that may be viewed with suspicion on overseas stock exchanges.

Telegram has exploded as a hub for cybercriminals looking to buy, sell and share stolen data and hacking tools, new research shows, as the messaging app emerges as an alternative to the dark web.An investigation by cyber intelligence group Cyberint, together with the Financial Times, found a ballooning network of hackers sharing data leaks on the popular messaging platform, sometimes in channels with tens of thousands of subscribers, lured by its ease of use and light-touch moderation.telegram from us


Telegram iOS Dev
FROM USA