Method, device, apparatus and computer-readable medium for displaying an image
By hiding the view to listen to the display mode switching event and binding the layer, using callback functions and extension methods to adjust the layer color, it solves the problem that the layer does not support dark mode, realizes the adaptation to the APP dark mode, and simplifies iOS dark mode adaptation process.
Patent Information
- Application Number
- CN202011010401.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-09-23
- Publication Date
- 2024-10-18
- Estimated Expiration
- 2040-09-23
AI Technical Summary
In the existing technology, layers do not support dark mode, making it difficult for images in the APP to adapt to dark mode.
Listen to the display mode switching event by hiding the view, bind the layer, and use callback functions and extension methods to adjust the color of the layer to adapt to dark mode.
It is realized that layers that do not support dark mode can also adapt to the dark mode in the APP, reducing the workload of iOS adapting to dark mode without affecting the native method.
Smart Images

Figure CN113760419B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a method, device, equipment and computer-readable medium for displaying an image. Background Art
[0002] Dark mode is an application mode with light text and dark background. Dark mode has been newly added to the mobile terminal system, and can be turned on through system settings. In dark mode, all adapted applications (Apps) will switch to dark mode display.
[0003] In the process of implementing the present invention, the inventors found that there are at least the following problems in the prior art: since the layers involved in displaying images do not support the dark mode, it is difficult for images in the APP to adapt to the dark mode. Summary of the invention
[0004] In view of this, embodiments of the present invention provide a method, apparatus, device and computer-readable medium for displaying an image, which can adapt to the dark mode in an APP for layers that do not support the dark mode.
[0005] To achieve the above object, according to one aspect of an embodiment of the present invention, a method for displaying an image is provided, comprising:
[0006] Listening is performed through a hidden view, the hidden view is generated when the color type of a layer in a control is set, the layer does not support a dark mode, and the layer is bound to the hidden view;
[0007] The hidden view monitors a display mode switching event and has preset a dark mode;
[0008] Adjusts the colors of the layers in the controls in the displayed image to match the dark mode according to the preset display colors.
[0009] The layer includes CALayer;
[0010] The hidden view is generated by setting the color type of the layer using an extension method, and the color type includes one or more of the following: border color, background color, and shadow color.
[0011] The layer and the hidden view are bound using the extended attributes of the hidden view.
[0012] The adjusting the color of the layer in the control in the display image according to the preset display color to adapt to the dark mode includes:
[0013] The callback function is used to adjust the color of the layer in the control in the display image according to the preset display color to adapt to the dark mode.
[0014] The method of using a callback function to adjust the color of the layer in the control in the display image according to a preset display color to adapt to the dark mode includes:
[0015] Through the bound hidden view, a callback function is used to adjust the color of the layer in the control in the displayed image according to the preset display color to adapt to the dark mode.
[0016] The hidden view provides an entry for the callback function;
[0017] The method of using a callback function to adjust the color of the layer in the control in the display image according to a preset display color to adapt to the dark mode includes:
[0018] Through the entry of the callback function, the color of the layer in the control in the display image is adjusted according to the preset display color to adapt to the dark mode.
[0019] The adjusting the color of the layer in the control in the display image according to the preset display color to adapt to the dark mode includes:
[0020] After obtaining the preset display color from the color type of the hidden view, the color of the layer in the control in the display image is adjusted according to the preset display color to adapt to the dark mode.
[0021] The preset display color is a color set corresponding to the dark mode, or a pre-set color.
[0022] According to a second aspect of an embodiment of the present invention, there is provided a device for displaying an image, comprising:
[0023] A monitoring module, used for monitoring through a hidden view, wherein the hidden view is generated when the color type of a layer in a control is set, the layer does not support a dark mode, and the layer is bound to the hidden view;
[0024] A determination module, used to determine that the hidden view monitors a display mode switching event and a dark mode has been preset;
[0025] The adjustment module is used to adjust the color of the layer in the control in the display image according to the preset display color to adapt to the dark mode.
[0026] The layer includes CALayer;
[0027] The hidden view is generated by setting the color type of the layer using an extension method, and the color type includes one or more of the following: border color, background color, and shadow color.
[0028] According to a third aspect of an embodiment of the present invention, there is provided an electronic device for displaying an image, comprising:
[0029] one or more processors;
[0030] a storage device for storing one or more programs,
[0031] When the one or more programs are executed by the one or more processors, the one or more processors implement the above method.
[0032] According to a fourth aspect of an embodiment of the present invention, there is provided a computer-readable medium on which a computer program is stored, and when the program is executed by a processor, the method as described above is implemented.
[0033] One embodiment of the above invention has the following advantages or beneficial effects: monitoring through a hidden view, the hidden view is generated when setting the color type of the layer in the control, the layer does not support the dark mode, and the layer is bound to the hidden view; the hidden view monitors the display mode switching event and the dark mode is preset; the color of the layer in the control in the display image is adjusted according to the preset display color to adapt to the dark mode. Binding the hidden view and the layer, using the hidden view to monitor the display mode switching event, is suitable for layers that do not support the dark mode. Therefore, for layers that do not support the dark mode, it can also adapt to the dark mode in the APP.
[0034] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with the specific implementation manner. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.
[0036] Figure 1 This is a schematic diagram of the output of the color object and view class layer in normal mode and dark mode;
[0037] Figure 2 is a schematic diagram of the main process of a method for displaying an image according to an embodiment of the present invention;
[0038] Figure 3 is a schematic diagram of a process of generating a hidden view according to an embodiment of the present invention;
[0039] Figure 4 is a schematic diagram of setting a layer using an extended method according to an embodiment of the present invention;
[0040] Figure 5 is a schematic diagram of updating the color of a layer by using a callback function according to an embodiment of the present invention;
[0041] Figure 6 is a schematic flow chart of a method for displaying an image according to an embodiment of the present invention;
[0042] Figure 7 is a schematic diagram of the main structure of a device for displaying images according to an embodiment of the present invention;
[0043] Figure 8 is an exemplary system architecture diagram to which embodiments of the present invention may be applied;
[0044] Fig. 9 It is a schematic diagram of the structure of a computer system of a terminal device or a server suitable for implementing an embodiment of the present invention. DETAILED DESCRIPTION
[0045] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.
[0046] A new dark mode is added to the mobile terminal system. Specifically, configure the adaptive color object (UIColor) in dark mode. Dynamic functions are added to UIColor. A UIColor can return different display colors depending on whether the current APP is in normal mode or dark mode.
[0047] Although dynamic adaptation is added to UIColor of common view classes, including background color and font color, etc., dynamic adaptation is not added to the layers of view classes. If you want to implement dynamic adaptation, you need to listen to system events and add a lot of additional processing.
[0048] See also Figure 1 , Figure 1 This is a schematic diagram of the output of the color object and view class layer in normal mode and dark mode.
[0049] Figure 1 There are two images in it, namely, Figure 1 And Vision Figure 2 .See Figure 1 Belongs to the color object, see Figure 2 Belongs to the layer. Figure 1 For normal mode, it is set to green, and for dark mode, it is set to red; Figure 2 For example, the normal mode is set to green and the dark mode is set to red.
[0050] In normal mode, the Figure 1 Display green, Figure 2 Displays green. In dark mode, Figure 1Display red, Figure 2 It still displays green. This is because the Figure 2 The layer does not have dynamic adaptation function and cannot adapt to dark mode.
[0051] Therefore, the layers involved in displaying images do not support the dark mode, making it difficult for images in the APP to adapt to the dark mode.
[0052] In order to solve the problem that the layers involved in displaying images do not support the dark mode, resulting in the difficulty of adapting the images in the APP to the dark mode, the following technical solutions in the embodiments of the present invention can be adopted.
[0053] See also Figure 2 , Figure 2 Schematic diagram of the main process of the method for displaying an image according to an embodiment of the present invention, binding hidden views and layers, monitoring the display mode switching event, and adjusting the color of the layer. Figure 2 As shown, the specific steps include:
[0054] S201. Listening is performed through a hidden view. The hidden view is generated when the color type of the layer in the control is set. The layer does not support dark mode. The layer is bound to the hidden view.
[0055] The technical solution in the embodiment of the present invention is applied to a mobile terminal. As an example, it can be applied to an Android system or an iOS system. The following is an exemplary description of the application to the iOS system, but it is not limited to the application to the iOS system. The control is the most frequently used object in a mobile terminal and is the base class of all view controls. It mainly includes buttons, texts, input boxes, and pictures.
[0056] In iOS, controls can be UIView. Most visible controls in iOS are UIView. UIView can be displayed on the screen because it has a layer inside. The layer can be CALayer. UIView provides the basis for CALayer display. UIView is responsible for handling touch events and participating in the event response chain. CALayer is only responsible for providing display content.
[0057] CALayer is a rectangular layer that manages image-based content and animation displays. It is often used to store views and is also used as a display without views. The main job of the layer is to manage visual effects, including the layer's own visual properties, such as background color, border, and shadow. In addition, the layer also saves the geometric content it displays on the screen, such as position, size, and transform.
[0058] In iOS, only view classes can listen to display mode switching events, and CALayer does not inherit from view classes, so CALayer cannot listen to display mode switching events. CALayer belongs to the system class. As an example, view classes include UIView.
[0059] Since the layer does not belong to the view class, it cannot listen to the display mode switching event. In this case, you can create a hidden view and listen to the display mode switching event through the hidden view. This is because the hidden view belongs to the view class. It can be understood that the hidden view is generated when the color type of the layer in the control is set.
[0060] See also Figure 3 , Figure 3 1 is a schematic diagram of a process of generating a hidden view according to an embodiment of the present invention, which specifically includes:
[0061] S301. Use the extension method to set the color type of the layer and the color type of the hidden view. The color types include one or more of the following: border color, background color, and shadow color.
[0062] Considering that CALayer usually sets one or more of the border color, background color, and shadow color in iOS, it is difficult to adapt to dark mode.
[0063] In the embodiment of the present invention, the color in the layer is adjusted by the hidden view. When the layer includes multiple color types, it is necessary to set the color consistent with the color type of the layer in the hidden view to ensure that the layer adapts to the dark mode. In other words, the hidden view is generated when the color type of the layer in the control is set. And the layer does not support the dark mode.
[0064] In the embodiment of the present invention, the color type of the layer and the color type of the hidden view are set by using an extension method, and the color type includes one or more of the following: border color, background color, and shadow color.
[0065] It should be noted that the color types of the layer are consistent with the color types of the hidden view and correspond to each other.
[0066] See also Figure 4 , Figure 4 is a schematic diagram of setting a layer using an extended method according to an embodiment of the present invention, specifically including:
[0067] The layer is specifically CALayer. CALayer includes three color categories, namely border color, background color and shadow color. According to the extension, set its own border color scheme, set its own background color scheme and set its own shadow color scheme. Among them, extension (Category) is a special technology in iOS programming. Extension can add functions based on the original class.
[0068] Therefore, the hidden view also includes three color categories. As an example, the hidden view can be a UIView class. The three color categories are specifically border color, background color, and shadow color. According to the extension, set the hidden view border color scheme, set the hidden view background color scheme, and set the hidden view shadow color scheme.
[0069] S302: Generate a hidden view.
[0070] Create a bound view class to generate a hidden view. The color of the hidden view corresponds to the color of the layer. The function of the bound view class is to monitor the system's display mode switching event (traitCollectionDidChange).
[0071] It is understandable that the hidden view is generated by setting the color type of the layer using the extension method. The layer is bound to the hidden view.
[0072] exist Figure 3 In an embodiment, the color type of the layer is set to correspond to the color type of the hidden view, so that the color of the layer is adjusted based on the hidden view.
[0073] Hidden view belongs to the bound view class, so hidden view can be used to listen to display mode switching events. Bind hidden view and layer, so that you can use hidden view to listen to display mode switching events, and when hidden view listens to display mode switching events, you can adjust the color in the layer.
[0074] In one embodiment of the present invention, in order to bind the hidden view and the layer, the extended attribute of the hidden view can be used to bind the hidden view and the layer. It can be understood that the layer and the hidden view are bound by using the extended attribute of the hidden view.
[0075] That is, add a view-binding property to the hidden view. As an example, if the hidden view is a UIView system class, add a view-binding property. For example, use the associatedObject method of runtime to add a view-binding property to the UIView system class to avoid affecting the native method of UIView.
[0076] That is to say, based on the original properties of the hidden view, the properties of the hidden view are added, so the native methods in the original properties of the hidden view are not affected.
[0077] S202: The hidden view monitors a display mode switching event and a dark mode has been preset.
[0078] Hide View Figure 1 On the one hand, it is responsible for listening to display mode switching events, and on the other hand, it notifies the layer of the monitored display mode switching events to adapt to the dark mode.
[0079] In the embodiment of the present invention, adjusting the color of the layer in the control in the displayed image to the dark mode needs to meet two conditions: one condition is that the hidden view monitors the display mode switching event, and the other condition is that the dark mode has been preset.
[0080] See also Figure 5 , Figure 5 4 is a schematic diagram of updating the color of a layer by using a callback function according to an embodiment of the present invention.
[0081] The created binding view class can not only monitor the display mode switching event, but also provide a callback function. When the user switches the display mode, the display mode switching event is triggered, and the hidden view monitors the display mode switching event. The callback function of the hidden view is used to update the color of the layer in the displayed image.
[0082] In other words, the callback function can be used to adjust the color of the layer in the control within the displayed image to adapt to the dark mode.
[0083] In one embodiment of the present invention, taking into account the binding relationship between the hidden view and the layer, when the display mode switching event is monitored, the color of the layer in the control in the display image can be adjusted according to the preset display color through the bound hidden view and a callback function to adapt to the dark mode.
[0084] In one embodiment of the present invention, the hidden view provides an entry for the callback function, so that the color of the layer in the control within the displayed image can be adjusted in time according to the preset display color through the entry for the callback function to adapt to the dark mode.
[0085] S203: adjusting the color of the layer in the control within the display image according to the preset display color to adapt to the dark mode.
[0086] In one embodiment of the present invention, the color type of the hidden view corresponds to the color type in the layer, and after obtaining the preset display color from the color type of the hidden view, the color of the layer in the control in the display image can be adjusted according to the preset display color. It can be seen that the hidden view can not only monitor the display mode switching event, but also transmit the preset display color.
[0087] That is, the color of the layer in the control within the display image is adjusted according to the preset display color to adapt to the dark mode.
[0088] In one embodiment of the present invention, the preset display color is a color set corresponding to the dark mode. As an example, the preset display color of the border corresponding to the dark mode is black.
[0089] Or, the preset display color is a preset color. It is understandable that the preset display color is black.
[0090] In the above embodiment, the hidden view is used for monitoring. The hidden view is generated when the color type of the layer in the control is set. The layer does not support the dark mode, and the layer is bound to the hidden view; the hidden view monitors the display mode switching event and the dark mode is preset; the color of the layer in the control in the display image is adjusted according to the preset display color to adapt to the dark mode. Binding the hidden view and the layer, using the hidden view to monitor the display mode switching event, is suitable for layers that do not support the dark mode. Therefore, for layers that do not support the dark mode, they can also adapt to the dark mode in the APP.
[0091] The technical solution of the present invention is exemplarily described below in conjunction with the accompanying drawings, wherein the operating system of the mobile terminal is iOS, and the layer may be CALayer.
[0092] See also Figure 6 , Figure 6 is a flow chart of a method for displaying an image according to an embodiment of the present invention, which specifically includes:
[0093] S601. Set the color type of CALayer.
[0094] Use the extension method to set the color type of CALayer, where the color types of CALayer include: border color, background color, and shadow color.
[0095] S602: Determine whether the current system supports dark mode.
[0096] Determine whether the current system supports the dark mode. If the current system supports the dark mode, execute S603; if the current system does not support the dark mode, execute S607.
[0097] As an example, the system of the mobile terminal can determine whether it supports the dark mode according to the system version number.
[0098] S603: Generate a hidden view.
[0099] Generate a hidden view, whose properties are UIView. Extend the properties of the bound view for UIView, and bind the hidden view and CALayer.
[0100] S604: A display mode switching event is monitored.
[0101] The hidden view listens to the display mode switching event, which means the system instructs to switch the display mode.
[0102] S605: Determine whether it is a dark mode.
[0103] Determine whether the switched display mode is the dark mode. If the switched display mode is the dark mode, execute S606; if the switched display mode is the normal mode, execute S607.
[0104] S606: Display the color corresponding to the dark mode.
[0105] In the CALayer that displays the image, the color is displayed according to the dark mode color corresponding to the input color.
[0106] S607: Display the color corresponding to the normal mode.
[0107] In the CALayer that displays the image, the color is displayed according to the color of the normal mode corresponding to the input color.
[0108] In the above embodiment, the adaptation of CALayer can be implemented with only one line of code, thereby greatly reducing the workload of iOS adaptation to the dark mode, and it will not affect the native methods of UIView and CALayer.
[0109] See also Figure 7 , Figure 7 is a schematic diagram of the main structure of an apparatus for displaying an image according to an embodiment of the present invention. The apparatus for displaying an image can implement a method for displaying an image, such as Figure 7 As shown, the device for displaying an image specifically includes:
[0110] A monitoring module 701 is used to monitor through a hidden view, where the hidden view is generated when the color type of a layer in a control is set, the layer does not support a dark mode, and the layer is bound to the hidden view;
[0111] A determination module 702 is used to determine that the hidden view monitors a display mode switching event and a dark mode has been preset;
[0112] The adjustment module 703 is used to adjust the color of the layer in the control in the display image according to the preset display color to adapt to the dark mode.
[0113] In one embodiment of the present invention, the layer includes CALayer;
[0114] The hidden view is generated by setting the color type of the layer using an extension method, and the color type includes one or more of the following: border color, background color, and shadow color.
[0115] In one embodiment of the present invention, the layer and the hidden view are bound using the extended attributes of the hidden view.
[0116] In one embodiment of the present invention, the adjustment module 703 is specifically configured to use a callback function to adjust the color of the layer in the control in the display image according to a preset display color to adapt to the dark mode.
[0117] In one embodiment of the present invention, the adjustment module 703 is specifically used to adjust the color of the layer in the control in the display image according to the preset display color through the bound hidden view and the callback function to adapt to the dark mode.
[0118] In one embodiment of the present invention, the hidden view provides an entry for the callback function;
[0119] The adjustment module 703 is specifically used to adjust the color of the layer in the control in the display image according to the preset display color through the entry of the callback function to adapt to the dark mode.
[0120] In one embodiment of the present invention, the adjustment module 703 is specifically configured to obtain a preset display color from the color type of the hidden view, and then adjust the color of the layer in the control in the display image according to the preset display color to adapt to the dark mode.
[0121] In one embodiment of the present invention, the preset display color is a color set corresponding to the dark mode, or a pre-set color.
[0122] Figure 8 An exemplary system architecture 800 is shown to which the method for displaying an image or the apparatus for displaying an image according to the embodiments of the present invention can be applied.
[0123] like Figure 8 As shown, system architecture 800 may include terminal devices 801, 802, 803, a network 804, and a server 805. Network 804 is used to provide a medium for communication links between terminal devices 801, 802, 803 and server 805. Network 804 may include various connection types, such as wired, wireless communication links, or optical fiber cables, etc.
[0124] Users can use terminal devices 801, 802, and 803 to interact with server 805 through network 804 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 801, 802, and 803, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only examples).
[0125] The terminal devices 801 , 802 , and 803 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, desktop computers, and the like.
[0126] The server 805 may be a server that provides various services, such as a backend management server (only an example) that provides support for shopping websites browsed by users using the terminal devices 801, 802, and 803. The backend management server may analyze and process the received data such as product information query requests, and feed back the processing results (such as target push information, product information - only an example) to the terminal device.
[0127] It should be noted that the method for displaying an image provided in the embodiment of the present invention is generally executed by the server 805 , and accordingly, the device for displaying an image is generally disposed in the server 805 .
[0128] It should be understood that Figure 8 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0129] Reference below Fig. 9 , which shows a schematic diagram of the structure of a computer system 900 of a terminal device suitable for implementing an embodiment of the present invention. Fig. 9 The terminal device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0130] like Fig. 9 As shown, the computer system 900 includes a central processing unit (CPU) 901, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 902 or a program loaded from a storage part 908 into a random access memory (RAM) 903. In the RAM 903, various programs and data required for the operation of the system 900 are also stored. The CPU 901, the ROM 902, and the RAM 903 are connected to each other via a bus 904. An input / output (I / O) interface 905 is also connected to the bus 904.
[0131] The following components are connected to the I / O interface 905: an input section 906 including a keyboard, a mouse, etc.; an output section 907 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 908 including a hard disk, etc.; and a communication section 909 including a network interface card such as a LAN card, a modem, etc. The communication section 909 performs communication processing via a network such as the Internet. A drive 910 is also connected to the I / O interface 905 as needed. A removable medium 911, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 910 as needed, so that a computer program read therefrom is installed into the storage section 908 as needed.
[0132] In particular, according to the embodiments disclosed in the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 909, and / or installed from the removable medium 911. When the computer program is executed by the central processing unit (CPU) 901, the above-mentioned functions defined in the system of the present invention are executed.
[0133] It should be noted that the computer-readable medium shown in the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0134] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0135] The modules involved in the embodiments of the present invention may be implemented in software or hardware. The modules described may also be provided in a processor. For example, they may be described as follows: a processor includes a sending unit, an acquisition unit, a determination unit, and a first processing unit. The names of these units do not, in some cases, constitute limitations on the units themselves. For example, the sending unit may also be described as a "unit that sends a request for obtaining an image to a connected server."
[0136] As another aspect, the present invention further provides a computer-readable medium, which may be included in the device described in the above embodiment; or may exist independently without being assembled into the device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by a device, the device includes:
[0137] Listening is performed through a hidden view, the hidden view is generated when the color type of a layer in a control is set, the layer does not support a dark mode, and the layer is bound to the hidden view;
[0138] The hidden view monitors a display mode switching event and has preset a dark mode;
[0139] Adjusts the colors of the layers in the controls in the displayed image to match the dark mode according to the preset display colors.
[0140] According to the technical solution of the embodiment of the present invention, the hidden view is used for monitoring. The hidden view is generated when the color type of the layer in the control is set. The layer does not support the dark mode, and the layer is bound to the hidden view; the hidden view monitors the display mode switching event and the dark mode is preset; the color of the layer in the control in the display image is adjusted according to the preset display color to adapt to the dark mode. Binding the hidden view and the layer, using the hidden view to monitor the display mode switching event, is suitable for layers that do not support the dark mode. Therefore, for layers that do not support the dark mode, they can also adapt to the dark mode in the APP.
[0141] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A method for displaying an image, characterized in that: include: Listening is performed through a hidden view, the hidden view is generated when the color type of a layer in a control is set, the layer does not support a dark mode, and the layer is bound to the hidden view; The hidden view monitors a display mode switching event and has preset a dark mode; Adjust the color of the layer in the control in the displayed image according to the preset display color to adapt to the dark mode; The adjusting the color of the layer in the control in the display image according to the preset display color to adapt to the dark mode includes: A callback function is used to adjust the color of the layer in the control in the display image according to the preset display color to adapt to the dark mode; The hidden view provides an entry for the callback function; The method of using a callback function to adjust the color of the layer in the control in the display image according to a preset display color to adapt to the dark mode includes: Through the entry of the callback function, the color of the layer in the control in the display image is adjusted according to the preset display color to adapt to the dark mode.
2. The method for displaying an image according to claim 1, characterized in that: The layer includes CALayer; The hidden view is generated by setting the color type of the layer using an extension method, and the color type includes one or more of the following: border color, background color, and shadow color.
3. The method for displaying an image according to claim 1, characterized in that: The layer and the hidden view are bound using the extended attributes of the hidden view.
4. The method for displaying an image according to claim 1, characterized in that: The method of using a callback function to adjust the color of the layer in the control in the display image according to a preset display color to adapt to the dark mode includes: Through the bound hidden view, a callback function is used to adjust the color of the layer in the control in the displayed image according to the preset display color to adapt to the dark mode.
5. The method for displaying an image according to claim 1, characterized in that: The adjusting the color of the layer in the control in the display image according to the preset display color to adapt to the dark mode includes: After obtaining the preset display color from the color type of the hidden view, the color of the layer in the control in the display image is adjusted according to the preset display color to adapt to the dark mode.
6. The method for displaying an image according to claim 1, characterized in that: The preset display color is a color set corresponding to the dark mode, or a pre-set color.
7. A device for displaying an image, characterized in that: include: A monitoring module, used for monitoring through a hidden view, wherein the hidden view is generated when the color type of a layer in a control is set, the layer does not support a dark mode, and the layer is bound to the hidden view; The hidden view provides an entry for the callback function; A determination module, used to determine that the hidden view monitors a display mode switching event and a dark mode has been preset; The adjustment module is used to adjust the color of the layer in the control in the display image according to the preset display color to adapt to the dark mode; specifically, through the entry of the callback function, the color of the layer in the control in the display image is adjusted according to the preset display color to adapt to the dark mode.
8. The device for displaying images according to claim 7, characterized in that: The layer includes CALayer; The hidden view is generated by setting the color type of the layer using an extension method, and the color type includes one or more of the following: border color, background color, and shadow color.
9. An electronic device for displaying an image, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 6.
10. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Display model switching method and device
CN107038037A
Underground pipeline management software system
CN107993178A
