Comments (11)
Hey :)
That is a very specific use case. Preferably, I would like to keep the card more generic.
One way of doing it, could be to add a tap gesture on the card and see if the tap is within the bounds of the image frame, which you can access from the optional imageLayer property that is set when you add an image.
from material.
Yeah I understand. That is a decent workaround, I'm using a UITapGestureRecognizer right now and it's still buggy as hell.
from material.
Actually, an even better approach would be to subclass the ImageCardView, which is a subclass of MaterialPulseView. Override the touchesBegan method, and if the touch is within the imageLayer execute your lightbox, if not, call the super.touchesBegan method.
from material.
public override func touchesBegan(touches: Set, withEvent event: UIEvent?) {
let point: CGPoint = layer.convertPoint(touches.first!.locationInView(self), fromLayer: layer)
if true == imageLayer?.containsPoint(point) {
...
} else {
super.touchesBegan(touches, withEvent: event)
}
}
I haven't tested the code, though this is the idea.
from material.
You can do the same with touchesEnd, which may be better to keep the pulse in general, though, you have to call super in that case to shrink the pulse.
from material.
Ahh interesting idea. I'll experiment! Thanks :)
(btw It's me, @cohix, I used the wrong account by accident)
from material.
Awesome :) How are you liking MaterialKit? We are planning a really awesome update shortly.
from material.
Liking it very much! I'm very happy with it so far
from material.
Great! Okay, after your experimentation, let us know how it worked out and close the ticket. All the best :)
from material.
Will do! Cheers.
from material.
I ended up using your solution, works quite well!
override func touchesEnded(touches: Set<UITouch>, withEvent event: UIEvent?)
{
let point: CGPoint = layer.convertPoint(touches.first!.locationInView(self), fromLayer: layer)
if imageLayer!.containsPoint(point)
{
// Show ligntbox
}
super.touchesEnded(touches, withEvent: event)
}
from material.
Related Issues (20)
- TabsController got Black View when Switching tab
- Module compiled with Swift 5.0.1 cannot be imported by the Swift 5.1.3 compiler
- Select chip
- [TAB BAR] How to setup tab bar for storyboard
- TextField left view rect not returning correct size
- Theme extension
- Swift 5 update
- Is this framework support Dark Mode?
- TextField does't refresh detailLabel
- Statusbar text color
- tabBar.tabBarStyle = .scrollable alignment to right
- Error with Xcode 12.0 HOT 1
- FABButton is rotated weird
- CGSize intrinsicContentSize on Xcode 12 HOT 2
- Cycle in dependencies between targets 'Material' and 'Motion'; building could produce unreliable results.
- crash when use in a framework target HOT 1
- Error installing with CocoaPods HOT 1
- MATERIAL
- Can not install any pod
- Seeking Guidance and Tips for Starting My UI/UX Design Journey
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from material.