Skip to content

Instantly share code, notes, and snippets.

@hansemannn
Created January 28, 2019 12:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hansemannn/1c60bde10bc377b1e08acf9c7208aa99 to your computer and use it in GitHub Desktop.
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.
import RoundedShadowView from 'rounded-shadow-view';
const view = new RoundedShadowView({ backgroundColor: 'red' }).instance;
// ... add to your window
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