ios 在文字里加图片

interface NSMutableAttributedString(CustomImage)


@param image 图片
@param point x水平偏移,但是排版位置不变,向后移动,会被截断,所以推荐使用空格实现水平偏移。
- (void)appendImageAttachment:(UIImage *)image offset:(CGPoint)point;


@implementation NSMutableAttributedString(CustomImage)

- (void)appendImageAttachment:(UIImage *)image offset:(CGPoint)point;
NSTextAttachment *attachment = [[NSTextAttachment alloc] init];
attachment.image = image;
attachment.bounds = CGRectMake(point.x, point.y, attachment.image.size.width, attachment.image.size.height);

NSAttributedString *attach = [NSAttributedString attributedStringWithAttachment:attachment];
[self appendAttributedString:attach];


无限的CABasicAnimation 在页面消失后再返回后被暂停

Actually there is a simple way to solve this
setting your animation to this

animation.removedOnCompletion = false

and the layer itself isn’t destroyed when NavigationController pushed another ViewController’s view, because UINavigationController got viewControllers property which will retain the original viewController and therefore its view and your animated layer. It is this CABasicAnimation object destroyed when view removed from interface even though you set its repeatCount to infinite. So set the removedOnCompletion to false to keep it


简单 Python 代码

import requests
from bs4 import BeautifulSoup
from pymongo import MongoClient

# mail
import smtplib
from email.mime.text import MIMEText
from email.header import Header
from email.mime.multipart import MIMEMultipart

database = "mongodb://"
client = MongoClient(database)
db = client.xmunv

def get_list():
    r = requests.session()
    html = r.get('').text
    soap = BeautifulSoup(html, "html.parser")
    container = soap.find(class_='module paged_list')
    news = container.findAll("li")
    return news

def print_list(news):
    for each in news:
        print("" % each.a.get('href'))

def lookup_database(news):
    for each in news:
        title = each.text.strip()
        url = "" % each.a.get('href')

        if{"title": title}) is None:
  {"title": title})
            push(title, url)

def push(title, url):
    text = """

    <a href="%s" >%s</a>

    """ % (title, url, url)
    print("pushing", title)

def send_mail(data):
    sender = '*********'
    smtp_server = ''
    username = sender
    password = '*********'
    smtp = smtplib.SMTP()
    smtp.login(username, password)

    receiver = ['']
    subject = '厦大经济学院新闻更新'
    msg = MIMEMultipart('alternative')
    part = MIMEText(data, 'html', 'utf-8')
    msg['Subject'] = Header(subject, 'utf-8')
    msg['from'] = sender
    smtp.sendmail(sender, receiver, msg.as_string())