Skip to content

Commit

Permalink
UIBlurView improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
XITRIX committed Dec 19, 2024
1 parent 2d6058c commit 37fdbc2
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions Submodules/UIKit/include/CABlurLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,14 @@ class CABlurLayer: public CALayer {
void setBlurValue(NXFloat blurValue);
[[nodiscard]] NXFloat blurValue() const { return _blurValue; }

void setBackgroundTintColor(UIColor backgroundTintColor) { _backgroundTintColor = backgroundTintColor; }
[[nodiscard]] UIColor backgroundTintColor() const { return _backgroundTintColor; }

std::optional<AnimatableProperty> value(std::string forKeyPath) override;

protected:
void update(std::shared_ptr<CALayer> presentation, std::shared_ptr<CABasicAnimation> animation, float progress) override;
UIColor _backgroundTintColor;

private:
NXFloat _blurValue = 10;
Expand Down
3 changes: 3 additions & 0 deletions Submodules/UIKit/include/UIBlurView.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ class UIBlurView: public UIView {
void setBlurValue(NXFloat blurValue) { _blurLayer()->setBlurValue(blurValue); }
[[nodiscard]] NXFloat blurValue() const { return _blurLayer()->blurValue(); }

void setBackgroundTintColor(UIColor backgroundTintColor) { _blurLayer()->setBackgroundTintColor(backgroundTintColor); }
[[nodiscard]] UIColor backgroundTintColor() const { return _blurLayer()->backgroundTintColor(); }

private:
std::shared_ptr<CABlurLayer> _blurLayer() const;
};
Expand Down
2 changes: 1 addition & 1 deletion Submodules/UIKit/lib/CABlurLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ void CABlurLayer::draw(SkCanvas* context) {
context->saveLayer(slr);
context->restore();

context->drawColor(0x40FFFFFF);
context->drawColor(_backgroundTintColor.raw());
context->restore();
}

Expand Down
1 change: 1 addition & 0 deletions app/Screens/TestViewController/TestViewController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ void TestViewController::loadView() {
blur->setFrame({ 80, 200, 240, 240 });
rootView->addSubview(blur);
blur->layer()->setCornerRadius(12);
blur->setBackgroundTintColor(0x60DDDDDD);

blur->addSubview(dragMeViewLabel);

Expand Down

0 comments on commit 37fdbc2

Please sign in to comment.