Created
January 28, 2019 12:11
-
-
Save hansemannn/1c60bde10bc377b1e08acf9c7208aa99 to your computer and use it in GitHub Desktop.
An example of using a cross-platform rounded shadow view in Appcelerator Titanium.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import RoundedShadowView from 'rounded-shadow-view'; | |
const view = new RoundedShadowView({ backgroundColor: 'red' }).instance; | |
// ... add to your window |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default class RoundedShadowView { | |
constructor(options = {}) { | |
this.options = options; | |
if (OS_ANDROID) { | |
this.containerView = Ti.UI.Android.createCardView({ | |
touchFeedback: true, | |
elevation: options.viewShadowRadius || 0 | |
}); | |
} else { | |
this.containerView = Ti.UI.createView(); | |
} | |
this.containerView.applyProperties(Object.assign({ | |
// Cross platform | |
viewShadowRadius: 16, | |
borderRadius: 10, | |
backgroundColor: 'white', | |
// iOS only | |
viewShadowColor: '#4d000000', | |
viewShadowOffset: { x: 0, y: 16 }, | |
// Android only | |
touchFeedbackColor: '#ccc', | |
}, options)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment