9

I need an delete button and want to use this trashcan icon you can find everywhere in iOS. How can I display this systemwide trashcan icon React Native instead of displaying my own icon in an Image-View?

1
  • Suggest marking @Jonathan Lockley's answer as correct. @talpaz's solution was written before react-native-vector-icons came into existence. Commented Mar 15, 2016 at 17:28

2 Answers 2

6

There is a node module you can use which gives you access to font icons the likes of Ion and FontAwesome where you can find pretty much any icon you want to use. It's really simple to install and use of iOS & Android. https://github.com/oblador/react-native-vector-icons

Sign up to request clarification or add additional context in comments.

3 Comments

This is the right answer, although unfortunately it doesn't work yet with <ToolbarAndroid>. github.com/oblador/react-native-vector-icons/issues/101
@jewbix.cube: It does with RN 0.21+
@oblador Yes, you are absolutely correct that it works now with RN 0.21+, and you helped me get it working. This question should be revisited so that Jonathan Lockely's answer can be marked as best.
1

That's a very good question, but I guess that's not possible.

In the iOS SDK the only way to display the standard icons is creating a certain type of UIBarButton by choosing the UIBarButtonSystemItem type as detailed here but as far as I've seen the React Native library doesn't create UIBarButton but only tapable elements like TEXT or composed view of IMAGE and TEXT wrapped in at TouchableHighlight so that specification doesn't seem to be exposed...

If someone finds a way in the iOS SDK, without using private API, to access the PNGs used in the standard button icons I think that behavior could be easily added to the the IMAGE class.

Stefano

1 Comment

Why not just wrap an <Image/> and a <Text/> in a <TouchableHighlight/>? Are the iOS images available somewhere?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.