CN117149195A - iOS system button content element arrangement method and device - Google Patents

iOS system button content element arrangement method and device Download PDF

Info

Publication number
CN117149195A
CN117149195A CN202311171289.9A CN202311171289A CN117149195A CN 117149195 A CN117149195 A CN 117149195A CN 202311171289 A CN202311171289 A CN 202311171289A CN 117149195 A CN117149195 A CN 117149195A
Authority
CN
China
Prior art keywords
button
content element
image
preset position
enumeration
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202311171289.9A
Other languages
Chinese (zh)
Inventor
丁汉飞
李骁
范世强
王楠
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Qichacha Technology Co ltd
Original Assignee
Qichacha Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Qichacha Technology Co ltd filed Critical Qichacha Technology Co ltd
Priority to CN202311171289.9A priority Critical patent/CN117149195A/en
Publication of CN117149195A publication Critical patent/CN117149195A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/38Creation or generation of source code for implementing user interfaces

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Human Computer Interaction (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)

Abstract

The invention provides a method and a device for arranging button content elements of an iOS system. The invention seamlessly integrates the sub-classified button control with the standard UIButton by sub-classifying the existing UIButton component and introducing the custom attribute adopting the enumeration attribute, so that a developer can accurately position the image in the button, and greater design flexibility and customization options are provided for the design. And by allowing free image positioning, a developer can create a user interface with attractive and intuitive appearance, which meets the specific design requirements of the developer. The sub-classified button controls are seamlessly integrated with the standard uibeton.

Description

iOS system button content element arrangement method and device
Technical Field
The invention relates to the technical field of computers, in particular to a method and a device for arranging button content elements of an iOS system.
Background
In the iOS development field, buttons are widely used for user interaction and triggering specific operations. However, existing iOS UIButton components have certain limitations in image localization. For modification of image position, the position of the picture can be modified by modifying the three attributes imageEdgeInsets, titleEdgeInsets, contentEdgeInsets in UIButton, however, this method requires relatively complex calculation to assign the three attribute values, is too complex, and the layout of the button control is out of the scope of itself, resulting in abnormality in the automated layout
Disclosure of Invention
The invention aims to provide an iOS system button content element arrangement method and device.
The invention provides a method for arranging button content elements of an iOS system, which comprises the following steps:
creating a new class button inherited from uibuton, the new class button inheriting standard button functions;
defining enumeration attributes, wherein the enumeration attributes are defined as preset positions of content elements in the new class buttons;
introducing custom attributes for realizing the content element positioning function into the new class button, wherein the custom attributes comprise the enumeration attributes;
and creating a layout logic method, acquiring the new type button and the content element information, calculating a content element offset according to a preset position appointed by the enumeration attribute, and adjusting a frame according to the content element offset.
As a further refinement of the invention, the content element comprises an image and text, and the self-determined attribute further comprises a spacing between the image and text information.
As a further improvement of the present invention, the preset positions include a first preset position, a second preset position, a third preset position and a fourth preset position, the first, second, third and fourth preset positions are respectively located at the upper side, the left side, the lower side and the right side in the new type button area, and the four preset positions are uniformly distributed at intervals.
As a further refinement of the present invention, defining the enumeration attribute further includes: the value of the enumeration attribute is set based on the center of the new class button.
As a further improvement of the present invention, the method of creating layout logic specifically includes:
and acquiring size information of the new type button, size information of the image and the image offset calculated according to the preset position, and adjusting the frame of the image to enable the acquired image to be located in the frame area of the new type button.
As a further improvement of the present invention, there is also included: the new class of buttons are associated with different operational events.
The present invention also provides an iOS system button content element arrangement apparatus, comprising:
a button creation module configured to create a new class button inherited from uibuton, the new class button inheriting standard button functions;
an enumeration attribute definition module configured to define an enumeration attribute as a preset position of a content element in the new class button;
an attribute definition module configured to introduce custom attributes in the new class button for implementing the content element positioning function, the custom attributes including the enumeration attributes;
and the rendering layout module is configured for creating a layout logic method, acquiring the new type button and the content element information, calculating a content element offset according to a preset position designated by the enumeration attribute, and adjusting a frame of the content element offset according to the content element offset.
As a further refinement of the invention, the content element comprises an image and text, and the self-determined attribute further comprises a spacing between the image and text information.
As a further improvement of the present invention, the preset positions include a first preset position, a second preset position, a third preset position and a fourth preset position, the first, second, third and fourth preset positions are respectively located at the upper side, the left side, the lower side and the right side in the new type button area, and the four preset positions are uniformly distributed at intervals.
As a further refinement of the present invention, defining the enumeration attribute further includes: the value of the enumeration attribute is set based on the center of the new class button.
As a further improvement of the present invention, the rendering layout module is configured to acquire size information of the new type button, size information of the image, and the image offset calculated according to the preset position, and adjust a frame of the image so that the acquired image is located in a new type button frame area.
As a further improvement of the invention, a button function configuration module is also included, which is configured for associating the new class of buttons with different operational events.
The beneficial effects of the invention are as follows: the invention seamlessly integrates the sub-classified button control with the standard UIButton by sub-classifying the existing UIButton component and introducing the custom attribute adopting the enumeration attribute, so that a developer can accurately position the image in the button, and greater design flexibility and customization options are provided for the design. And by allowing free image positioning, a developer can create a user interface with attractive and intuitive appearance, which meets the specific design requirements of the developer. The sub-classified button controls are seamlessly integrated with the standard uibeton.
Drawings
FIG. 1 is a schematic diagram showing the steps of a method for arranging content elements of an iOS system button in an embodiment of the invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the technical solutions of the present invention will be clearly and completely described below in conjunction with the detailed description of the present invention and the corresponding drawings. It will be apparent that the described embodiments are only some, but not all, of the embodiments of the invention. All other embodiments, which can be made by those skilled in the art based on the embodiments of the present invention without making any inventive effort, are intended to fall within the scope of the present invention.
Embodiments of the present invention are described in detail below, examples of which are illustrated in the accompanying drawings, wherein like or similar reference numerals refer to like or similar elements or elements having like or similar functions throughout. The embodiments described below by referring to the drawings are exemplary only for explaining the present invention and are not to be construed as limiting the present invention.
The present embodiment provides a method for arranging content elements of buttons of an iOS system, which is implemented based on an iOS system UIButton component, which is an interactable control in iOS development, and is used for creating buttons, triggering specific operations or responses, realizing button interaction and operations, and providing interface elements for application programs. Uibuton allows a user to click or touch for performing a particular operation or switching different application states, may associate buttons with a particular method or callback function, and may use an automatic layout to control the location and size of buttons to accommodate different device and screen sizes.
As shown in fig. 1, the present embodiment provides a method for arranging content elements of an iOS system button, which includes the steps of:
s1: a new class button, custom button, is created that inherits standard button functions from uibuton.
S2: an enumeration attribute imagePosition is defined, which is defined as a preset position of a content element in the new class button, customButton.
S3: and introducing custom attributes for realizing the content element positioning function into the new type button CustomButton, wherein the custom attributes comprise the enumeration attribute imagePosition.
S4: and creating a layout logic method, acquiring the new type button CustomButton and the content element information, calculating a content element offset according to a preset position designated by the enumeration attribute imagePosition, and adjusting a frame according to the content element offset.
In step S1, the custom button is defined as a subclass, and this subclass inherits from the standard button class UIButton provided by iOSSDK, which inherits all core functions and characteristics of the standard UIButton class, so that the custom button has the characteristics of free image positioning, and at the same time, retains the common behaviors and user interaction functions of the standard button.
In step S2 and step S3, the free positioning function of the content element is implemented by defining and introducing an enumeration property imagePosition, which is used to specify a preset position of the content element within the button. An enumeration property represents a set of named data types of a constant value set that define a set of possible options, states, types, etc. For example, enumeration properties may be used to represent different button states, interface modes, directions, etc. In this embodiment, the location attribute of the content element is defined using an enumeration attribute, allowing the developer to specify several fixed preset locations of the image within the button, making the process of positioning more intuitive and easy to understand.
Further, the content elements include images and texts, and other decorative elements, dynamic elements and the like can be added into the buttons besides the images and the texts.
Specifically, in this embodiment, the preset positions include a first preset position, a second preset position, a third preset position and a fourth preset position, where the first, second, third and fourth preset positions are located on the upper side, the left side, the lower side and the right side in the new type button custom button region, respectively, and the four preset positions are uniformly distributed at intervals.
The four positions of the upper, lower, left and right can meet the requirements of most image layout, and accurate positioning of content elements in the button can be realized by selecting proper preset positions. In other embodiments of the present invention, preset positions such as upper right, upper left, etc. may also be set according to layout requirements.
For the value of the custom attribute, the value of the enumeration attribute can be set based on the center of the new type button, so that the calculation process is more visual. In other embodiments of the present invention, the values of custom properties may also be set based on the boundaries of the buttons according to a specific button layout.
When a developer needs to place content elements such as images at specific positions in the button, the center of the button is simply considered, an appropriate preset position is selected according to design requirements, and then the value of the enumeration attribute imagePosition is set as a corresponding option. For example, if the developer wishes to place the content element on the upper side of the button, the value of imagePosition may be set to a first preset bit. Similarly, if they want to place the content element on the right side of the button, the value of imagePosition can be set to the fourth preset bit. In this way, the content elements will appear in the desired locations relative to the center of the buttons without cumbersome calculations and layout, making the interface design more flexible and intuitive.
Further, the self-determined attribute further comprises a distance between the image and the text information, and the distance attribute is used for adjusting the distance between the image and the text information, so that a developer can accurately control the layout between the image and the text information. By introducing the interval attribute, the attribute setting of the button is further enriched, the customization of the button is enhanced, and a larger design freedom degree is provided.
In step S4, it specifically includes: and acquiring size information of the new type button CustomButton, size information of the image and the image offset calculated according to the preset position, and adjusting the frame of the image to enable the acquired image to be positioned in the frame area of the new type button CustomButton.
By introducing image layout logic, the frame of the image is automatically adjusted at button rendering so that the image is accurately located within the frame area of the custom button. The size information of the custom button and the size information of the used image are obtained, and the image offset is calculated according to the preset position based on the selected enumeration attribute imagePosition. Then, the exact position of the image within the button can be calculated using the above information, and then the frame of the image is set to ensure that the image is accurately located within the frame area of the button.
Further, after the arrangement of the button content elements is completed, the new button custom button is associated with different operation events to realize standard user interaction processing, including clicking, touching, responding to other related events, and the like, or call a callback function defined by a developer, so that the required operation and behavior can be freely bound according to the use scene and the use requirement.
The present invention also provides an iOS system button content element arrangement apparatus, comprising:
a button creation module configured to create a new class button, customButton, inherited from UIButton, that inherits standard button functions;
an enumeration attribute imagePosition definition module configured to define an enumeration attribute imagePosition as a preset position of a content element in the new class button custom button;
an attribute definition module configured to introduce custom attributes for implementing the content element positioning function in the new class button CustomButton, the custom attributes including the enumeration attribute imagePosition;
and the rendering layout module is configured for creating a layout logic method, acquiring the new type button CustomButton and the content element information, calculating a content element offset according to a preset position designated by the enumeration attribute imagePosition, and adjusting a frame according to the content element offset.
The content element includes an image and text, and the self-determined attribute further includes a spacing between the image and text information.
The preset positions comprise a first preset position, a second preset position, a third preset position and a fourth preset position, and the first, second, third and fourth preset positions are respectively located at the upper side, the left side, the lower side and the right side in the novel button CustomButton area and are evenly distributed at intervals.
Defining the enumeration attribute imagePosition further includes: the value of the enumeration attribute imagePosition is set based on the center of the new class button CustomButton.
The rendering layout module is configured with size information of the omButton, size information of the image and the image offset calculated according to the preset position, and adjusts the frame of the image so that the obtained image is positioned in a new type button CustomButton frame area.
The iOS system button content element arrangement means further comprises a button function configuration module configured to associate the new class button CustomButton with different operational events. Set up to obtain the new class button post
In summary, the present invention seamlessly integrates the sub-classified button controls with the standard UIButton by sub-classifying the existing UIButton component and introducing custom properties using enumeration properties, enabling the developer to precisely locate images within the buttons, providing greater design flexibility and customization options for the design. And by allowing free image positioning, a developer can create a user interface with attractive and intuitive appearance, which meets the specific design requirements of the developer. The sub-classified button controls are seamlessly integrated with the standard uibeton.
It should be understood that although the present disclosure describes embodiments, not every embodiment is provided with a separate embodiment, and that this description is for clarity only, and that the skilled artisan should recognize that the embodiments may be combined as appropriate to form other embodiments that will be understood by those skilled in the art.
The above list of detailed descriptions is only specific to practical embodiments of the present invention, and is not intended to limit the scope of the present invention, and all equivalent embodiments or modifications that do not depart from the spirit of the present invention should be included in the scope of the present invention.

Claims (12)

1. An iOS system button content element arrangement method, characterized by comprising the steps of:
creating a new class button inherited from uibuton, the new class button inheriting standard button functions;
defining enumeration attributes, wherein the enumeration attributes are defined as preset positions of content elements in the new class buttons;
introducing custom attributes for realizing the content element positioning function into the new class button, wherein the custom attributes comprise the enumeration attributes;
and creating a layout logic method, acquiring the new type button and the content element information, calculating a content element offset according to a preset position appointed by the enumeration attribute, and adjusting a frame according to the content element offset.
2. The iOS system button content element arrangement method according to claim 1, wherein the content element comprises an image and text, and the self-determined attribute further comprises a spacing between the image and text information.
3. The iOS system button content element arrangement method according to claim 2, wherein the preset positions comprise a first preset position, a second preset position, a third preset position and a fourth preset position, wherein the first, second, third and fourth preset positions are respectively located at an upper side, a left side, a lower side and a right side in the new type button region, and the four positions are uniformly spaced.
4. The iOS system button content element arrangement method according to claim 2, wherein defining an enumeration attribute further comprises: the value of the enumeration attribute is set based on the center of the new class button.
5. The iOS system button content element arrangement method according to claim 2, wherein the creating a layout logic method comprises:
and acquiring size information of the new type button, size information of the image and the image offset calculated according to the preset position, and adjusting the frame of the image to enable the acquired image to be located in the frame area of the new type button.
6. The iOS system button content element arrangement method according to claim 1, further comprising: the new class of buttons are associated with different operational events.
7. An iOS system button content element arrangement apparatus, comprising:
a button creation module configured to create a new class button inherited from uibuton, the new class button inheriting standard button functions;
an enumeration attribute definition module configured to define an enumeration attribute as a preset position of a content element in the new class button;
an attribute definition module configured to introduce custom attributes in the new class button for implementing the content element positioning function, the custom attributes including the enumeration attributes;
and the rendering layout module is configured for creating a layout logic method, acquiring the new type button and the content element information, calculating a content element offset according to a preset position designated by the enumeration attribute, and adjusting a frame of the content element offset according to the content element offset.
8. The iOS system button content element arrangement means according to claim 7, wherein said content element comprises an image and text, and said self-determined attribute further comprises a spacing between said image and text information.
9. The iOS system button content element arrangement means according to claim 8, wherein the preset positions comprise a first preset position, a second preset position, a third preset position and a fourth preset position, wherein the first, second, third and fourth preset positions are respectively located at an upper side, a left side, a lower side and a right side in the new type button region, and the four are uniformly spaced.
10. The iOS system button content element arrangement means according to claim 8, wherein defining an enumeration attribute further comprises: the value of the enumeration attribute is set based on the center of the new class button.
11. The iOS system button content element arrangement apparatus according to claim 8, wherein the rendering layout module is configured to acquire size information of the new type button, size information of the image, the image offset calculated according to the preset position, and adjust a frame of the image so that the acquired image is located within a new type button frame area.
12. The iOS system button content element arrangement means according to claim 8, further comprising a button function configuration module configured to associate the new class of buttons with different operational events.
CN202311171289.9A 2023-09-12 2023-09-12 iOS system button content element arrangement method and device Pending CN117149195A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311171289.9A CN117149195A (en) 2023-09-12 2023-09-12 iOS system button content element arrangement method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311171289.9A CN117149195A (en) 2023-09-12 2023-09-12 iOS system button content element arrangement method and device

Publications (1)

Publication Number Publication Date
CN117149195A true CN117149195A (en) 2023-12-01

Family

ID=88911811

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311171289.9A Pending CN117149195A (en) 2023-09-12 2023-09-12 iOS system button content element arrangement method and device

Country Status (1)

Country Link
CN (1) CN117149195A (en)

Similar Documents

Publication Publication Date Title
EP2656196B1 (en) Customization of an immersive environment
CN109893852B (en) Interface information processing method and device
US8645901B2 (en) Visualization and information display for shapes in displayed graphical images based on a cursor
US20170131874A1 (en) Software Design Tool For A User Interface And The Administration Of Proximity Responsive Information Displays In Augmented Reality Or Virtual Reality Environments
US11449314B2 (en) Rapid application development method
US20070260986A1 (en) System and method of customizing video display layouts having dynamic icons
WO2020186814A1 (en) Page element highlighting method, apparatus, device and storage medium
CN112445564B (en) Interface display method, electronic device and computer readable storage medium
US10908764B2 (en) Inter-context coordination to facilitate synchronized presentation of image content
US20170185422A1 (en) Method and system for generating and controlling composite user interface control
CN110174984B (en) Information processing method and electronic equipment
CN112445501A (en) Data burning method and device and computer readable storage medium
CN117149195A (en) iOS system button content element arrangement method and device
CN104615339A (en) Control showing method and device
US20200278996A1 (en) Electronic apparatus, method for controlling electronic apparatus, and storage medium
CN104216626A (en) Image obtaining method and electronic device
CN112579144A (en) Data processing method and device
CN111190523A (en) Interface processing method, terminal and computer readable storage medium
JP7155610B2 (en) Display program, display method and display control device
CN104850298A (en) Information processing method and electronic equipment
WO2024000111A1 (en) Desktop display method, electronic device, display apparatus and computer-readable storage medium
US11249732B2 (en) GUI controller design support device, system for remote control and program
CN112733506B (en) Page editing method, page editing system, electronic device and storage medium
CN115080671B (en) Method and device for creating user-defined relationship graph, storage medium and electronic equipment
EP3798821B1 (en) Gui controller design assistance device, remote control system, and program

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination