Coder Social home page Coder Social logo

dynamicblurview's Introduction

dynamicblurview's People

Contributors

akolov avatar basvankuijck avatar kiyot avatar kyoheig3 avatar m0rtymerr avatar mwfire avatar readmecritic avatar shroo0om avatar tthbalazs avatar xiao99xiao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dynamicblurview's Issues

This function contains crash info

func renderBelowLayer(_ layer: CALayer, in context: CGContext) {
let layers = hideOverlappedLayers(layer.sublayers)
layer.render(in: context) "context” may be nil
layers.forEach {
$0.isHidden = false
}
}

Swift 2.3 support

Hi!

I suggest to introduce a branch that works with swift 2.3.

Thanks
-Paolo

@NSManaged attribute applied to non-CoreData property

There's some strange property declaration:

…
public class DynamicBlurView: UIView {
private class BlurLayer: CALayer {
    @NSManaged var blurRadius: CGFloat
…

And official documentation says this:

Add the @NSManaged attribute before each property definition in your managed object subclass that corresponds to an attribute or relationship in your Core Data model. Like the @dynamic attribute in Objective-C, the @NSManaged attribute informs the Swift compiler that the storage and implementation of a property will be provided at runtime. However, unlike @dynamic, the @NSManaged attribute is available only for Core Data support.

And it doesn't look like that BlurLayer is related to Core Data in any way.

So, i think it's better to just to add some default value for blurRadius, or declare blurRadius as optional CGFloat, if the problem is in default value for this property.

Compilation issue: var current: `Self`

Hello @KyoheiG3,

'Self' is only available in a protocol or as the result of a method in a class; did you mean 'BlurLayer'?

var current: Self {
        presentation() ?? self
}

Hope for your soonest solutions.

  • DynamicBlurView pod version: [5.0.2]
  • Xcode version: [11.3]
  • Your application language: [Swift-4.2]

is inaccessible due to 'private' protection level error

I'm running an IOS 9.2 application which includes DynamicBlurView. It had been running without error and I just incurred 18 DynamicBlurView errors which states, "is inaccessible due to 'private' protection level error". How should I correct this issue.

Black view

Just followed the iOS 8+ example and applied it to an image view and it shows a completely black view.
Any ideas?

    if let imageView = self.bannerImage {
        let blurView = DynamicBlurView(frame: imageView.bounds)
        blurView.blurRadius = 10
        imageView.addSubview(blurView)
    }

EDIT: This is called from awakeFromNib()

Swift 4.1 . Support

Doesn't build under latest Xcode 9.3 with Swift 4.1 compiler.
Issue related to using private variables from DynamicBlurView extensions - so you just have to make them fileprivate

DynamicBlurView as subview of modal presented View Controller appear like view with black background

At UIViewController i add DynamicBlurView as subview. After that i present that View Controller modaly and DynamicBlurView looks like just black view.

`
class BlurViewController: UIViewController {

override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .clear

let blur = DynamicBlurView(frame: CGRect(x: 20, y: 20, width: 300, height: 300))
view.addSubview(blur)
blur.blurRadius = 10
blur.dynamicMode = .common

}
`
screen shot 2016-11-28 at 18 23 31

Transparent background

Would like to blur some view, but leave the view behind it still visible instead of using a solid color. Have tried with isOpaque set to false, but then the view that's being blurred is still visible. Hiding this view causes the blurred content to disappear as well.

Is there a way to achieve what I'm looking for?

Thanks.

Rarely does a black shadow occur

Rarely does a black shadow occur

  • 1 , Once in a while appear shadow
    It's a tricky question,
    The iPhone 8 Plus and the iPhone 12 Mini have appeared sporadily so far.

tapd_36120278_base64_1609828842_41

Swift 4 support

For some reason Im not able to pull the Swift4 version support on Pod install.. the version I’m pulling has an issue calling UIView.layer not in the main Thread.. can you provide advice ?

Doesn't work in UIPageViewController

I have a 3 page UIPageViewController with the center page being the initial screen.

My BlurView is on the right-most page (page 3). A snapshot image of the entire Page 2 shows up scaled into my blurview on Page 3.

Swift 3 support

Hi!
I'd love to help DynamicBlurView to be ported to Swift 3. Can we create a new branch for that?

Thanks
-Paolo

CGContextSetInterpolationQuality error

Here's that's spat out in the debugger:

<Error>: CGContextSetInterpolationQuality: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context  and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.

Blur View pushes image behind it down

When adding a blur radius to the blur layer the imageview behind it pushes the image down.
Here is the example...

`class TestViewController: UIViewController {

@IBOutlet weak var blurView: DynamicBlurView!

override func viewDidLoad() {
    super.viewDidLoad()
    
    blurView.blurRadius = CGFloat(5)
}

override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(animated)
}

}`

untitled

screen shot 2016-12-30 at 4 39 26 pm

Very odd behaviour?

EXC_BAD_ACCESS on iPhone5, iOS8.4, Xcode7-beta5, Swift 2.0

<Error>: copy_read_only: vm_copy failed: status 1.

Xcode referred to line 340 of DynamicBlurView.swift:

if let bitmap = CGBitmapContextCreateImage(bitmapContext) {

I don't do anything fancy with the DynamicBlurView.
Stacktrace:

#0  0x3a670ae6 in _platform_memmove ()
#2  0x2bb09b6a in CGBitmapContextCreateImage ()
#3  0x0032ac78 in ext.DynamicBlurView.ObjectiveC.UIImage.blurredImage (ObjectiveC.UIImage(CoreGraphics.CGFloat, iterations : Swift.Int, ratio : CoreGraphics.CGFloat, blendColor : Swift.Optional<ObjectiveC.UIColor>) -> Swift.ImplicitlyUnwrappedOptional<ObjectiveC.UIImage> at /.../DynamicBlurView/DynamicBlurView.swift:340
#4  0x0032afd8 in @objc ext.DynamicBlurView.ObjectiveC.UIImage.blurredImage (ObjectiveC.UIImage)(CoreGraphics.CGFloat, iterations : Swift.Int, ratio : CoreGraphics.CGFloat, blendColor : Swift.Optional<ObjectiveC.UIColor>) -> Swift.ImplicitlyUnwrappedOptional<ObjectiveC.UIImage> ()
#5  0x0032bce8 in DynamicBlurView.DynamicBlurView.((setCaptureImage in _2044C6510BFEB36C5566C936E3D26E26) (DynamicBlurView.DynamicBlurView) -> (ObjectiveC.UIImage, radius : CoreGraphics.CGFloat) -> ()).(closure #1) at /.../DynamicBlurView/DynamicBlurView.swift:197    
#6  0x00328854 in DynamicBlurView.DynamicBlurView.(setCaptureImage in _2044C6510BFEB36C5566C936E3D26E26) (DynamicBlurView.DynamicBlurView)(ObjectiveC.UIImage, radius : CoreGraphics.CGFloat) -> () at /.../DynamicBlurView/DynamicBlurView.swift:207
#7  0x0032bac4 in DynamicBlurView.DynamicBlurView.(displayLayer (DynamicBlurView.DynamicBlurView) -> (ObjectiveC.CALayer) -> ()).(closure #1) at /.../DynamicBlurView/DynamicBlurView.swift:168

The problem only occurs on my iPhone. The simulator works fine though.

Resolved in #4

Crash within the Blur Layer

Exception Type: SIGSEGV
Exception Codes: SEGV_ACCERR at 0x16904ee488
Crashed Thread: 0

Thread 0 Crashed:
0 CoreGraphics 0x00000001ed830ddc CGColorGetAlpha + 12
1 QuartzCore 0x00000001f0086bf4 -[CALayer _renderBorderInContext:] + 144
2 QuartzCore 0x00000001f0088b5c -[CALayer renderInContext:] + 1396
3 QuartzCore 0x00000001f0086ea4 -[CALayer _renderSublayersInContext:] + 368
4 QuartzCore 0x00000001f0088b48 -[CALayer renderInContext:] + 1376
5 QuartzCore 0x00000001f0086ea4 -[CALayer _renderSublayersInContext:] + 368
6 QuartzCore 0x00000001f0088b48 -[CALayer renderInContext:] + 1376
7 QuartzCore 0x00000001f0086ea4 -[CALayer _renderSublayersInContext:] + 368
8 QuartzCore 0x00000001f0088b48 -[CALayer renderInContext:] + 1376
9 QuartzCore 0x00000001f0086ea4 -[CALayer _renderSublayersInContext:] + 368
10 QuartzCore 0x00000001f0088b48 -[CALayer renderInContext:] + 1376
11 QuartzCore 0x00000001f0086ea4 -[CALayer _renderSublayersInContext:] + 368
12 QuartzCore 0x00000001f0088b48 -[CALayer renderInContext:] + 1376
13 QuartzCore 0x00000001f0086ea4 -[CALayer _renderSublayersInContext:] + 368
14 QuartzCore 0x00000001f0088b48 -[CALayer renderInContext:] + 1376
15 QuartzCore 0x00000001f0086ea4 -[CALayer _renderSublayersInContext:] + 368
16 QuartzCore 0x00000001f0088b48 -[CALayer renderInContext:] + 1376
17 QuartzCore 0x00000001f0086ea4 -[CALayer _renderSublayersInContext:] + 368
18 QuartzCore 0x00000001f0088b48 -[CALayer renderInContext:] + 1376
19 QuartzCore 0x00000001f0086ea4 -[CALayer _renderSublayersInContext:] + 368
20 QuartzCore 0x00000001f0088b48 -[CALayer renderInContext:] + 1376
21 QuartzCore 0x00000001f0086ea4 -[CALayer _renderSublayersInContext:] + 368
22 QuartzCore 0x00000001f0088b48 -[CALayer renderInContext:] + 1376
23 DynamicBlurView 0x00000001060da560 DynamicBlurView.BlurLayer.render(in: __C.CGContextRef, for: __C.CALayer) -> () (BlurLayer.swift:94)
24 DynamicBlurView 0x00000001060df684 DynamicBlurView.DynamicBlurView.(snapshotImage in _2044C6510BFEB36C5566C936E3D26E26)(for: __C.CALayer, conversion: Swift.Bool) -> __C.UIImage? (DynamicBlurView.swift:142)
25 DynamicBlurView 0x00000001060dffd8 function signature specialization <Arg[0] = Dead> of DynamicBlurView.DynamicBlurView.display(__C.CALayer) -> () (DynamicBlurView.swift:156)
26 DynamicBlurView 0x00000001060df7b4 @objc DynamicBlurView.DynamicBlurView.display(__C.CALayer) -> () (:0)
27 DynamicBlurView 0x00000001060df934 DynamicBlurView.DynamicBlurView.refresh() -> () (DynamicBlurView.swift:180)
28 PopupDialog 0x000000010ae77240 PopupDialog.PresentationController.containerViewWillLayoutSubviews() -> () (PresentationController.swift:58)
29 PopupDialog 0x000000010ae77288 merged @objc PopupDialog.PresentationController.presentationTransitionWillBegin() -> () + 24
30 UIKitCore 0x0000000219386fe4 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1116
31 libobjc.A.dylib 0x00000001eacab454 -[NSObject performSelector:withObject:] + 64
32 QuartzCore 0x00000001f0083db4 -[CALayer layoutSublayers] + 184
33 QuartzCore 0x00000001f00840a0 CA::Layer::layout_if_needed(CA::Transaction*) + 332
34 QuartzCore 0x00000001f0083f1c -[CALayer layoutIfNeeded] + 228
35 QuartzCore 0x00000001f0088690 -[CALayer renderInContext:] + 168
36 DynamicBlurView 0x00000001060da560 DynamicBlurView.BlurLayer.render(in: __C.CGContextRef, for: __C.CALayer) -> () (BlurLayer.swift:94)
37 DynamicBlurView 0x00000001060df684 DynamicBlurView.DynamicBlurView.(snapshotImage in _2044C6510BFEB36C5566C936E3D26E26)(for: __C.CALayer, conversion: Swift.Bool) -> __C.UIImage? (DynamicBlurView.swift:142)
38 DynamicBlurView 0x00000001060de828 DynamicBlurView.DynamicBlurView.didMoveToWindow() -> () (DynamicBlurView.swift:86)
39 DynamicBlurView 0x00000001060de944 merged @objc DynamicBlurView.DynamicBlurView.didMoveToWindow() -> () + 24
40 UIKitCore 0x000000021937e288 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 1604
41 UIKitCore 0x000000021937dedc -[UIView(Internal) _didMoveFromWindow:toWindow:] + 664
42 UIKitCore 0x00000002193712ac __45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke + 156
43 Foundation 0x00000001ec437634 -[NSISEngine withBehaviors:performModifications:] + 112
44 UIKitCore 0x000000021937118c -[UIView(Hierarchy) _postMovedFromSuperview:] + 816
45 UIKitCore 0x0000000219380d20 -[UIView(Internal) _addSubview:positioned:relativeTo:] + 1740
46 PopupDialog 0x000000010ae76d74 PopupDialog.PresentationController.presentationTransitionWillBegin() -> () (PresentationController.swift:40)
47 PopupDialog 0x000000010ae77288 merged @objc PopupDialog.PresentationController.presentationTransitionWillBegin() -> () + 24
48 UIKitCore 0x000000021882dc8c __71-[UIPresentationController _initViewHierarchyForPresentationSuperview:]_block_invoke + 2224
49 UIKitCore 0x000000021882b6e0 __56-[UIPresentationController runTransitionForCurrentState]_block_invoke + 468
50 UIKitCore 0x000000021890fa64 __40+[UIViewController _scheduleTransition:]_block_invoke + 24
51 UIKitCore 0x0000000218edd1fc _runAfterCACommitDeferredBlocks + 300
52 UIKitCore 0x0000000218ecb3bc _cleanUpAfterCAFlushAndRunDeferredBlocks + 352
53 UIKitCore 0x0000000218ef9a3c _afterCACommitHandler + 116
54 CoreFoundation 0x00000001eba3a0e8 CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION + 32
55 CoreFoundation 0x00000001eba34be0 __CFRunLoopDoObservers + 412
56 CoreFoundation 0x00000001eba35140 __CFRunLoopRun + 1208
57 CoreFoundation 0x00000001eba34964 CFRunLoopRunSpecific + 448
58 GraphicsServices 0x00000001edc75d8c GSEventRunModal + 104
59 UIKitCore 0x0000000218ed1758 UIApplicationMain + 212
60 VW-R-CLUB Member APP 0x000000010292ffdc main (AppDelegate.swift:20)
61 libdyld.dylib 0x00000001eb4f0fd8 start + 0

crash report:

func render(in context: CGContext, for layer: CALayer) {
    let layers = hideOverlappingLayers(layer.sublayers)
    layer.render(in: context)    <------------------------------ here
    layers.forEach {
        $0.isHidden = false
    }
}


private func snapshotImage(for layer: CALayer, conversion: Bool) -> UIImage? {
    let rect = blurLayerRect(to: layer, conversion: conversion)
    guard let context = CGContext.imageContext(with: quality, rect: rect, opaque: isOpaque) else {
        return nil
    }

    blurLayer.render(in: context, for: layer)  <------------------------------ here

    defer {
        UIGraphicsEndImageContext()
    }

    return UIGraphicsGetImageFromCurrentImageContext()
}


extension DynamicBlurView {
open override func display(_ layer: CALayer) {
    let blurRadius = blurLayer.presentationRadius
    let isFixes = isDeepRendering && staticImage != nil
    if let view = renderingTarget, let image = staticImage ?? snapshotImage(for: view.layer, conversion: !isFixes) {   <------------------------------ here <Arg[0] = Dead> of DynamicBlurView.DynamicBlurView.display(__C.CALayer) -> () (DynamicBlurView.swift:156)
        draw(image, blurRadius: blurRadius, fixes: isFixes, baseLayer: view.layer)
    }
}

}

extension DynamicBlurView {
/// Remove cache of blur image then get it again.
open func refresh() {
    blurLayer.refresh()
    staticImage = nil
    blurRatio = 1
    display(layer) <------------------------------ here
}

Hope you can help me to fix it.

The crash only happens sometimes.

New release

@KyoheiG3 we need a new release on GitHub for both CocoaPods and Swift Package Manager.

Thanks!

Black boxes when scrolling collection view.

Hello! I'm trying to add this lib to an app where we have an UICollectionView and when I scroll through the cells, some of them turn into a black box for a fraction of the second. And also some of the blurred images go to the wrong cell.

The problem happens when I scroll and change the blurView alpha to 0. (that change is done automatically on scrolling outside a certain offset)

config:

        blurView.frame = textLabel.bounds
        blurView.drawsAsynchronously = true
        blurView.trackingMode = .tracking
        blurView.quality = .low
        blurView.isDeepRendering = true
        blurView.backgroundColor = .white
        blurView.iterations = 2

Build Errors

Hey! Awesome Library!

There are a few build errors. I guess it's an iOS 8.2 thing. Anyways, here is how I fixed them:

In "DynamicBlurView.swift"

1)

Near the top

private var blurLayer: BlurLayer {
return layer as! BlurLayer
}

should be...

private var blurLayer: BlurLayer {
return layer as BlurLayer
}

2)

public override func displayLayer(layer: CALayer!)

let blurRadius: CGFloat

should be...

var blurRadius: CGFloat

3)

func blurredImage(radius: CGFloat, iterations: Int, ratio: CGFloat, blendColor: UIColor?)

let tempBuffer = malloc(tempSize)

should be...

let tempBuffer = malloc(UInt(tempSize))

4)

func blurredImage(radius: CGFloat, iterations: Int, ratio: CGFloat, blendColor: UIColor?)

let ctx = CGBitmapContextCreate(inBuffer.data, Int(inBuffer.width), Int(inBuffer.height), 8, inBuffer.rowBytes, space, bitmapInfo)

should be...

let ctx = CGBitmapContextCreate(inBuffer.data, UInt(inBuffer.width), UInt(inBuffer.height), 8, inBuffer.rowBytes, space, bitmapInfo)

5)

func blurredImage(radius: CGFloat, iterations: Int, ratio: CGFloat, blendColor: UIColor?)

CGContextFillRect(ctx, CGRect(x: 0, y: 0, width: width, height: height))

should be...

CGContextFillRect(ctx, CGRectMake(0, 0, CGFloat(width), CGFloat(height)))

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.