You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在React Native中访问iOS/Android原生分享图标?

Hey there! Great question—using system-native share icons without adding extra packages or icon files is totally feasible, and it keeps your app nice and lean. Let’s break this down for iOS and Android separately:

iOS 原生分享图标实现

Starting with React Native 0.68+, the Image component has built-in support for SF Symbols—Apple’s native icon library. The share icon you’re looking for is named square.and.arrow.up, and you can use it directly like this:

import { Image } from 'react-native';

// iOS native share icon (SF Symbols)
<Image
  systemName="square.and.arrow.up"
  size={24} // Adjust size as needed
  color="#000" // Set your desired color
/>

This pulls directly from iOS’s system icons, so it’ll match the style of the user’s device (light/dark mode, iOS version updates) automatically—no extra files or dependencies required.

Android 原生分享图标实现

Android comes with a built-in share icon in its system drawables, typically named ic_menu_share. You can reference this directly in React Native using the Image component’s source prop with the system resource URI:

import { Image, Platform } from 'react-native';

// Cross-platform native share icon component
const NativeShareIcon = () => {
  if (Platform.OS === 'ios') {
    return (
      <Image
        systemName="square.and.arrow.up"
        size={24}
        color="#000"
      />
    );
  } else {
    return (
      <Image
        source={{ uri: 'android.resource://android/drawable/ic_menu_share' }}
        style={{
          width: 24,
          height: 24,
          tintColor: '#000' // Adjust color here
        }}
      />
    );
  }
};

// Use the component wherever you need a share icon
<NativeShareIcon />

A quick note: The exact icon name might vary slightly across Android versions or custom ROMs, but ic_menu_share is the standard one that works on most devices. The tintColor prop lets you match the icon to your app’s theme, just like iOS’s color prop.

If you need to handle different states (like pressed/highlighted), you could extend this component with platform-specific state handling, but the above code covers the basic, dependency-free use case.

Hope this gets you set up with native share icons in no time!

内容的提问来源于stack exchange,提问作者tommy chheng

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 09:45:18